.htaccess redirect one domain to another incliuding specific query string
basally I need to redirect
http://www.old-domain.com/news.php?NewsID=30888
to
http://w开发者_运维百科ww.new-domain.com/news.php?NewsID=30888
using htaccess however only if the query string is as above. Any other query strings I need to continue to go to
http://www.old-domain.com/news.php?NewsID=whatever_querystring.
So I need to match the 30888 and then redirect to a whole new site including the news.php?NewsID=30888
.
Thanks in advance
Put this code in your .htaccess and try;
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteCond %{QUERY_STRING} ^NewsID=30888 [NC]
RewriteCond %{HTTP_HOST} ^www\.old-domain\.com$ [NC]
RewriteRule ^ http://www.new-domain.com%{REQUEST_URI}?%{QUERY_STRING} [R=301,L]
You have to test your Query string and the host name:
RewriteCond %{QUERY_STRING} NewsID=30888 [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?old-domain\.com$ [NC]
RewriteRule ^/(.*) http://www.new-domain.com/$1 [L,R]
精彩评论