下面是我的样本网址:
http://mydomain.com/folder/subfolder/index.php?site=www.othersite.com
我要重写这种方式:
http://mydomain.com/folder/subfolder/www.othersite.com
我试图
RewriteEngine on
RewriteBase /folder/subfolder/
RewriteRule ^([A-Za-z0-9\-\.]+)$ index.php?site=$1 [L]
我打印数组$ _GET并返回网站参数为价值'的index.php',它没有返回'www.othersite.com
i printed the array $_GET and returns the value of the 'site' parameter as 'index.php', it didn't return 'www.othersite.com'
如何才能做到这一点?
感谢
在你的.htaccess文件试试这个规则:
Try this rule in your .htaccess file:
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteCond %{QUERY_STRING} !^site= [NC]
RewriteRule ^(folder/subfolder)/(.*)$ /$1/index.php?site=$2 [L,NC,QSA]