[英]htaccess rewrite rule not working correctly
I have the following htaccess file 我有以下htaccess文件
Options +FollowSymLinks
RewriteEngine On
#profile view
RewriteRule ^([a-zA-Z0-9.]+)/?$ profile.php?id=$1
When i go to my url and type http://www.mysite.com/username
当我转到我的网址并输入
http://www.mysite.com/username
then in profile.php file i have 然后在profile.php文件中我有
<?php
print_r($_GET);
die();
?>
and it prints out 它打印出来
Array ( [id] => profile.php )
where it should have printed out 应该打印出来的地方
Array ( [id] => "username" )
So i guess there is something wrong in my rewrite rule? 所以我想我的重写规则有问题吗?
#profile view
RewriteRule ^([a-zA-Z0-9.]+)?$ profile.php?id=$1
try that 试试看
EDIT: 编辑:
RewriteRule ^(.*)?$ profile.php?id=$1 [QSA] RewriteRule ^(。*)?$ profile.php?id = $ 1 [QSA]
OR 要么
RewriteRule ^([a-zA-Z0-9.]+)?$ profile.php?id=$1 [QSA] RewriteRule ^([a-zA-Z0-9。] +)?$ profile.php?id = $ 1 [QSA]
最后添加QSA:
RewriteRule ^([a-zA-Z0-9.]+)/?$ profile.php?id=$1 [QSA]
Try this htaccess code : 试试这个htaccess代码:
RewriteEngine On
RewriteRule ^([^/]+)$ /profile.php?id=$1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.