【问题标题】:Hide a part of a URL with mod_rewrite but keep the argument使用 mod_rewrite 隐藏 URL 的一部分但保留参数
【发布时间】:2013-08-02 13:12:11
【问题描述】:

我想写一个规则,members/show/ 字符串将隐藏在 URL 中。

原始 URL:localhost:8080/sandbox/member/show/helloworld,其中helloworld 是帐户名称。我希望它是localhost:8080/sandbox/m/helloworld。基本上,交付的内容将来自完整的 url,但我希望它对任何用户都隐藏。

RewriteRule ^.*$ member/show/$0 [L,QSA] 似乎不起作用,它会引发 500 内部服务器错误。我使用 CodeIgniter 框架,并且已经存在以下重写规则:RewriteRule .* index.php/$0 [PT,L]

我尝试了几个 RewriteRule 选项,但没有成功。如果有人能对我的问题有所了解,我将非常高兴。

最好的问候。

【问题讨论】:

    标签: php mod-rewrite


    【解决方案1】:

    通过httpd.conf启用mod_rewrite和.htaccess,然后把这段代码放到你.htaccessDOCUMENT_ROOT目录下:

    Options +FollowSymLinks -MultiViews
    # Turn mod_rewrite on
    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^(sandbox)/m/([^/]+)/?$ /$1/member/show/$2 [L,NC]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-12
      • 1970-01-01
      • 2018-10-06
      • 2016-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-25
      相关资源
      最近更新 更多