如何在htaccess的重写规则用,在URL的参数(点或周期) [英] how to create a rewrite rule in htaccess with .(dot or period) in the parameter of the url
本文介绍了如何在htaccess的重写规则用,在URL的参数(点或周期)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我的样本网址:
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]
这篇关于如何在htaccess的重写规则用,在URL的参数(点或周期)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文