Question

Here is what I need to redirect to a temporary HTML page:

http://www.domain1.com/?Itemid=230

should get redirected to:

http://www.domain2.com/temoporary-solution.html

Here is what I came up with, just not sure if it will cause any issues between the rest of the .htaccess rules (this is the first rule):

RewriteCond %{HTTP_HOST}  ^www\.domain1\.com$ [NC]
RewriteCond %{QUERY_STRING}  ^Itemid=230$ [NC]
RewriteRule ^$ http://domain2.com/temoporary-solution.html [R=302,NE,NC,L]
Was it helpful?

Solution

Your rule should work fine. Just append ? at the end of target URI to strip off existing query string:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com$ [NC]
RewriteCond %{QUERY_STRING} ^Itemid=230$ [NC]
RewriteRule ^$ http://domain2.com/temoporary-solution.html? [R=302,L]

OTHER TIPS

Those rules are fine. The conditions are pretty strict so as long as it's the first rule, it won't break anything else.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top