我在重写规则后尝试从网址中获取参数时遇到问题
这是我的网址:
www.mysite.com/pages/example/two /
这应该加载我的重写规则
www.mysite.com/pages/page.php?user=two
以下是我的重写规则
RewriteEngine on
RewriteRule ^example/(.+)/?$ page.php?user=$1 [NC,L]
我有两个参数的第二条规则
RewriteRule ^example/(.+)/(.+)$ page.php?user=$1&lang=$2 [NC,L,QSA]
我的php中有一个var_dump ($_GET['user']);
,但是我得到的结果为 NULL 和PHP注意:未定义的索引:用户在第4行的/path/page.php中。 >
有什么主意吗?预先感谢。
答案 0 :(得分:0)
尝试一下:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^example/(.*)/?$ page.php?user=$1 [NC,QSA]
RewriteRule ^example/(.*)/(.*)$ page.php?user=$1&lang=$2 [NC,QSA]