Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
3.0k views
in Q2A Core by
I have a number of URLs indexed in Google as follows:
domain.com/25/ask  (when clicking it, it show a page with title: What is a cat)

So, I edited the end of .htaccess with this entry:
redirect 301 /25/ask http://www.domain.com/25/what-is-a-cat

However, when clicking or going to domain.com/25/ask, I'm redirected to:

http://domain.com/25/what-is-a-cat/?qa-rewrite=25/ask

My question...  Why is .htaccess adding ?QA-REWRITE=25/ask to the end of the URL and how do I remove that from these "hard coded 301 redirect settings?"

2 Answers

0 votes
by

Try adding [L] to the end of your redirect line (and put it first in the htaccess file). The [L] will tell the server to stop processing additional lines in the htaccess.

by
Thanks for your help and response.  I'll be able to access/work on the site later, but are you saying to simply change the lines to:

redirect 301 /25/ask http://www.domain.com/25/what-is-a-cat [L] ?

Thanks again.
by
Putting the line first in the htaccess file make no difference.  Putting it first with a trailing [L] results in a 500 error message.

I'll have to read up on the proper syntax, any ideas?
by
I think I found the solution to do manual "301 style" redirects in the default .htaccess file.

On the third line (after the line that reads "RewriteEngine On")

Paste:

RewriteRule ^25/ask$ http://www.domain.com/25/what-is-a-cat [R=301,L]

Where 25/ask is the "bad url" and then you have the url you want the viewer to be forwarded to.  (The Redirect 301 method doesn't work because adding [L] after that line is improper syntax.)
0 votes
by

Below is a solution to do manual "301 style" redirects in the default .htaccess file.

On the third line (after the line that reads "RewriteEngine On")

Paste:

RewriteRule ^25/ask$ http://www.domain.com/25/what-is-a-cat [R=301,L]

Where 25/ask is the "bad url" and then you have the url you want the viewer to be forwarded to.  (The Redirect 301 method doesn't work because adding [L] after that line is improper syntax.)

I hope this is helpful to others.  If there's a better way to accomplish the above, please comment.  Thanks!

by
Shouldn´t it be after the Rewrite Base line ?
by
I'm no .htaccess expert, but the solution above works for me.  I find if you add these manual redirects at the end of the file (or anywhere else) it doesn't function properly.  For example, the trailing L causes the .htaccess to "stop" after a rule is triggered.  If you were to put these manual rules at any other location (especially the bottom of the file) they may not even be called/work.
...