【发布时间】:2014-06-04 17:40:24
【问题描述】:
这是我的 htaccess:
RewriteEngine On
RewriteCond %{REQUEST_URI} !/(lib|assets|index\.php) [NC]
RewriteRule ^/?$ index.php?p=index [L,QSA]
RewriteCond %{REQUEST_URI} !/(lib|assets|index\.php) [NC]
RewriteRule ^(.+)$ index.php?p=$1 [L,QSA]
RewriteRule ^(profiles\/\w+)$ index.php?p=profiles
关于最后一条规则,我想重写这个网址:
/profiles/史蒂夫
到
index.php?p=profiles&user=Steve
现在,当我进入 mysite/profiles/ 时,它会起作用,但现在我需要添加 &u=Steve,所以:
RewriteRule ^(profiles\/\w+)$ index.php?p=profiles&u=$1
当我访问 mysite/profiles/Steve 时
我会收到 404 错误。
为什么这不起作用以及如何解决?
编辑:
现在我有了这个:
RewriteRule ^profiles/(.+?)/?$ index.php?p=profiles&u=$1 [L,QSA]
(感谢乔恩·林) 但现在我有这个作为输出:(print_r($_GET);):
Array ( [p] => profiles/Steve )
我想要:
Array ( [p] => profiles [u] => Steve )
固定,规则最先于其他重写规则。
【问题讨论】:
标签: .htaccess mod-rewrite url-rewriting