Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-07-2008, 02:28 AM   PM User | #1
zenweezil
Regular Coder

 
Join Date: Jan 2003
Posts: 111
Thanks: 2
Thanked 0 Times in 0 Posts
zenweezil is an unknown quantity at this point
Question .htaccess redirect not workign when %20 is in old url

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?
zenweezil is offline   Reply With Quote
Old 03-07-2008, 03:05 AM   PM User | #2
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
Quote:
Originally Posted by zenweezil View Post
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:

Code:
Redirect 301 http://www.mynewsite.com/contact\ us.htm http://www.mynewsite.com/contact.php
or better use this:
Code:
RewriteRule ^contact\ us\.htm$ http://www.mynewsite.com/contact.php [R=301,L]
:
best regards
oesxyl is offline   Reply With Quote
Old 03-07-2008, 03:20 AM   PM User | #3
zenweezil
Regular Coder

 
Join Date: Jan 2003
Posts: 111
Thanks: 2
Thanked 0 Times in 0 Posts
zenweezil is an unknown quantity at this point
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.
zenweezil is offline   Reply With Quote
Old 03-07-2008, 03:52 AM   PM User | #4
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
This should work
Code:
Redirect 301 "/contact us.html" http://www.mynewsite.com/contact.php
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Users who have thanked _Aerospace_Eng_ for this post:
zenweezil (03-07-2008)
Old 03-07-2008, 03:58 AM   PM User | #5
zenweezil
Regular Coder

 
Join Date: Jan 2003
Posts: 111
Thanks: 2
Thanked 0 Times in 0 Posts
zenweezil is an unknown quantity at this point
Thumbs up

WE HAVE A WINNER!! Thank you that worked perfectly!


Quote:
Originally Posted by _Aerospace_Eng_ View Post
This should work
Code:
Redirect 301 "/contact us.html" http://www.mynewsite.com/contact.php
zenweezil is offline   Reply With Quote
Old 01-12-2011, 05:48 PM   PM User | #6
brandonb
New to the CF scene

 
Join Date: Jan 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
brandonb is an unknown quantity at this point
Option that Worked Also

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.

Code:
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.
brandonb is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:36 PM.


Advertisement
Log in to turn off these ads.