开发者

Rewrite URL (Apache): Creating 301 redirects

开发者 https://www.devze.com 2023-01-28 20:21 出处:网络
I recently restru开发者_如何学Goctured my site, moving away from querystring parameters to friendly urls.The url structure I used to use was mysite.com/?site=www.somesite.com/.I am now using the site

I recently restru开发者_如何学Goctured my site, moving away from querystring parameters to friendly urls. The url structure I used to use was mysite.com/?site=www.somesite.com/. I am now using the site parameter as part of the page's path, with my new url structure being mysite.com/site/www.somesite.com

I cannot figure out the proper rewrite rule to for my .htaccess file to redirect the old url structure to the new


Put this in your .htaccess file:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^site=(.*)$
RewriteRule .* /site/%1 [L,R=301]

Edit: In reply to comment #3

Change RewriteRule to:

RewriteRule .* /site/%1? [L,R=301]
0

精彩评论

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