0

I have just updated and I am currently setting all of the 301 Redirects in Apache's htaccess file. All redirects are working with the current format.

Redirect 301 /old+url+4343/ http://www.newsite.com/new-url-here/ 

But I've noticed a lot of old urls have some encoding - mainly ones with questions for titles. Apaches htaccess seems to ignore the encoding or just flop and not do anything. This, for example does not work;

Redirect 301 /old+question+title%3F/ http://www.newsite.com/new-question-title%3F/ 

In this case the %3F should be a question mark (?). I can visit the site normally if I copy and paste the url - that works just fine.

I have also tried setting the Charset in htaccess to see if that work but unfortunately it didnt, this was the code;

AddDefaultCharset UTF-8 

Any ideas on why Apache would ignore url encoding and how I could overwrite that?

1 Answer 1

1

Redirect directive is very limited, better to use RewriteRule for regex capabilities and flags like NE:

RewriteEngine On RewriteRule ^old\+question\+title\x3F/ /new-question-title\%3F/ [L,NC,NE,R=302] 
Sign up to request clarification or add additional context in comments.

3 Comments

btw this is properly tested rule so I would appreciate a reason of downvote here
Hi @anubhava , thank you for the answer - unfortunately it doesn't seem to work (I have not downvoted by the way). The htaccess file seems to be ignoring the rule like before. Do I need to escape any slashes in the url for directories?
Can you tell me full URL you used to great and location of this htaccess?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.