[英]unable to get parameters in php after rewrite rule
I have a problem when I try to get a parameter from the url after rewriting a rule 改写规则后尝试从网址中获取参数时出现问题
This is my url: 这是我的网址:
www.mysite.com/pages/example/two/
www.mysite.com/pages/example/two/
and this one is supposed to load my rewrite rule 这应该加载我的重写规则
www.mysite.com/pages/page.php?user=two
www.mysite.com/pages/page.php?user=two
The following is my rewrite rule 以下是我的重写规则
RewriteEngine on
RewriteRule ^example/(.+)/?$ page.php?user=$1 [NC,L]
I have a second rule for two parameters 我有两个参数的第二条规则
RewriteRule ^example/(.+)/(.+)$ page.php?user=$1&lang=$2 [NC,L,QSA]
I have a var_dump ($_GET['user']);
我有一个
var_dump ($_GET['user']);
in my php, but I get result as a NULL and PHP Notice: Undefined index: user in /path/page.php on line 4. 在我的php中,但得到的结果为NULL和PHP注意:未定义的索引:用户在第4行的/path/page.php中
Any idea? 任何想法? Thanks in advance.
提前致谢。
Try this: 尝试这个:
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]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.