【问题标题】:htaccess variables not working with usernamehtaccess 变量不适用于用户名
【发布时间】:2013-11-30 05:26:05
【问题描述】:

所以我有一个用户名的重写规则如下

RewriteEngine On
RewriteBase /test/

Options FollowSymLinks
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} ^(.*)$

RewriteRule ^/?([A-Z0-9a-z\~\^\(\)_\-\+\{\}\[\]\|:\<\>\.]+)$ index.php?user=$1 [L]

这很好用,我可以 echo $_GET['user'] 没问题。当我按如下方式向重写规则添加另一个变量时会出现问题 -

RewriteRule ^/?([A-Z0-9a-z\~\^\(\)_\-\+\{\}\[\]\|:\<\>\.]+)$/?extra$ index.php?user=$1&system_page=extra [L]

我希望能够访问 http//localhost/test/username/extra 并以“extra”的结果回显 $_GET['system_page'],但我收到了 404 错误。

对此的任何帮助都非常感谢。

【问题讨论】:

    标签: php .htaccess mod-rewrite get


    【解决方案1】:

    好的,想通了。对于遇到相同问题的任何人,解决方案是删除用户名定义后的“$”。

    RewriteRule ^/?([A-Z0-9a-z\~\^\(\)_\-\+\{\}\[\]\|:\<\>\.]+)$/?extra$
    

    应该是 -

    RewriteRule ^/?([A-Z0-9a-z\~\^\(\)_\-\+\{\}\[\]\|:\<\>\.]+)/?extra$
    

    【讨论】:

      猜你喜欢
      • 2019-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-18
      • 1970-01-01
      相关资源
      最近更新 更多