...

View Full Version : .htaccess redirect not workign when %20 is in old url



zenweezil
03-07-2008, 02:28 AM
I am redesigned a site and setting up the .htaccess 301 redirects and noticed the old urls with spaces (%20) in them will not redirect.

All the others are redirecting correctly. Here is an example of one that won't work:

Redirect 301 /contact%20us.htm http://www.mynewsite.com/contact.php



Thoughts?

oesxyl
03-07-2008, 03:05 AM
I am redesigned a site and setting up the .htaccess 301 redirects and noticed the old urls with spaces (%20) in them will not redirect.

All the others are redirecting correctly. Here is an example of one that won't work:

Redirect 301 /contact%20us.htm http://www.mynewsite.com/contact.php

Thoughts?

try this:



Redirect 301 http://www.mynewsite.com/contact\ us.htm http://www.mynewsite.com/contact.php


or better use this:


RewriteRule ^contact\ us\.htm$ http://www.mynewsite.com/contact.php [R=301,L]

:
best regards

zenweezil
03-07-2008, 03:20 AM
Neither of those worked. The first one caused an error - even when I removed the full url in the first reference. The second just didn't redirect.

_Aerospace_Eng_
03-07-2008, 03:52 AM
This should work

Redirect 301 "/contact us.html" http://www.mynewsite.com/contact.php

zenweezil
03-07-2008, 03:58 AM
WE HAVE A WINNER!! Thank you that worked perfectly!



This should work

Redirect 301 "/contact us.html" http://www.mynewsite.com/contact.php

brandonb
01-12-2011, 05:48 PM
I was running into the same problem. This is the solution that worked for me on http://www.mycollegesandcareers.com which we're running on an Ubuntu server.


redirectMatch 301 ^/careers[\s]/(.*)$ http://www.mycollegesandcareers.com/careers/$1

the whole [\s] is regular expression for any whitespace. It's the only thing that would work for me. I couldn't get any of the suggested stuff above to work.

Hope this helps someone else that is in the same boat as I was.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum