0

I'm trying to 301 the following url

http://www.site.com/reviews/4f64d2862c16bf4ae40000b4?sort=all-positive 

to

http://www.site.com/reviews

By using

RewriteRule ^reviews/([a-fA-f0-9]+)?$ http://www.site.com/reviews [L,R=301]

But that redirects me to

http://www.site.com/reviews?sort=all-positive

How can I remove all query strings after what was the review id? Basically the question mark and everything after it needs to go. Any ideas?

Thanks!

Ken
  • 626
  • 1
  • 8
  • 22

1 Answers1

1

You have to use this RewriteRule: RewriteRule ^reviews/([a-fA-F0-9]+)?$ http://www.site.com/reviews/$1? [L,R=301] The $1 puts the id at the end of the url, the "?" deletes the query.

I have also changed "A-f" to "A-F", but I do not think this is neccessary.

Edit There is already a similar question in SO: mod_rewrite: remove query string from URL?

Community
  • 1
  • 1
Christopher
  • 2,005
  • 3
  • 24
  • 50