.htaccess redirect without query string

I am trying to redirect (note the query lines):

http://www.reviews.com/review/review_review.cfm?review_id=135223 

to

 http://www.reviews.com/ 

Current Rule:

 Redirect 301 /review/review_review.cfm http://www.reviews.com/ 

Causes the original URL to redirect to http://www.reviews.com/?review_id=135223

Based on a few questions on the stack here and here , should I add ? to the redirection rule as shown below:

 Redirect 301 /review/review_review.cfm http://www.reviews.com/? 

but is it redirecting to http://www.reviews.com/? . The end? stays. How do I get rid of this, it kills me.

+4
source share
1 answer

Can't you get rid of an outsider ? using mod_alias. ? will prevent the addition of a query string, but with mod_alias, unfortunately, does it include ? as part of a redirect. However, mod_rewrite will not, because the addition ? to the end, which tells him not to include any existing query string, works the same as mod_alias, but after that it is processed by mod_alias again, minus the final ? so the end result doesn't end ? at the end of the url. So something like:

 RewriteEngine On RewriteRule ^/?review/review_review.cfm$ http://www.reviews.com/? [L,R=301] 

And that will replace the Redirect statement.

+14
source

All Articles