Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jan 2003
    Posts
    111
    Thanks
    2
    Thanked 0 Times in 0 Posts

    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?

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    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

  • #3
    Regular Coder
    Join Date
    Jan 2003
    Posts
    111
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    zenweezil (03-07-2008)

  • #5
    Regular Coder
    Join Date
    Jan 2003
    Posts
    111
    Thanks
    2
    Thanked 0 Times in 0 Posts

    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

  • #6
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •