-1

我现在的网址结构:

domain.com/items/view/5
domain.com/user/view/5
domain.com/user/edit/5

现在我不希望用户直接知道 url 中的“id”,因为他们可以直接从地址栏中触发查询。
因此,我想将 url 屏蔽为:

domain.com

即 domain.com/anything 将按原样出现,但 url 不会改变。

提前致谢。

另请注意,我已经使用以下代码制作了 .htaccess 文件,以从 url 中删除“index.php”,并且效果很好。

    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ /index.php/$1 [L]
    </IfModule>
4

1 回答 1

1

做不到。隐藏 id 的唯一方法是将其传递到 url 之外 - 即作为 POST 数据;但.htaccess无权访问,只有网址。

相反,您的代码应该处理这样一个事实,即用户可以直接输入 url 并正确操作或使用 http-redirect 标头将用户发送回主页。

于 2013-08-23T08:54:59.700 回答