While I was cleaning up URL structures on an Open Cart eCommerce platform I ran into an problem with the 301 redirections. Every time I would use the following code I would get a ? (question mark) appending the URL:
code: RedirectPermanent /old-url http://www.sample.com/new-url
results: http://www.sample.com/new-url?
I found out the correct solution for this was to use a RewriteRule:
code: RewriteRule ^old-url$ http://www.sample.com/new-url [L,R=301]
Notice on the “old URL” I did not include the domain or the starting directory /.
Using this code will hopefully help save you time as it did for me. Please be careful when modifying .htaccess files as it can take your site down faster than Mohammad Ali could in his prime!
If you have any feedback or suggestions please comment below.
On side note I would not recommend using OpenCart as it lacks greatly when it comes to SEO, but I will leave that story to another post.