开发者

how to create a rewrite rule in htaccess with .(dot or period) in the parameter of the url

开发者 https://www.devze.com 2023-03-01 00:15 出处:网络
here is my sample url: http://mydomain.com/开发者_开发知识库folder/subfolder/index.php?site=www.othersite.com

here is my sample url:

http://mydomain.com/开发者_开发知识库folder/subfolder/index.php?site=www.othersite.com

i want to rewrite it this way:

http://mydomain.com/folder/subfolder/www.othersite.com

i tried

RewriteEngine on

RewriteBase /folder/subfolder/

RewriteRule ^([A-Za-z0-9\\-\\.]+)$ index.php?site=$1 [L]

i printed the array $_GET and returns the value of the 'site' parameter as 'index.php', it didn't return 'www.othersite.com'

how can this be done?

thanks,


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]
0

精彩评论

暂无评论...
验证码 换一张
取 消