2

I have some 301 redirect rules failing because of capital letters in the URL. Problem is... that is how they appeared in the old site, so I would like them to be case-sensitive.

This doesn't work:

Redirect 301 /folder/HeyThere.html http://www.newsite.com

but this does

Redirect 301 /folder/heythere.html http://www.newsite.com

Doesn't seem like a lower-case character rule applies to both upper-case and lower-case letters, but I need to have this work for URLs with upper-case letters in them. I'd like to have it work for both, but is there something I can do to ensure this works properly if someone comes from a URL with an upper-case character?

2 Answers 2

1

You better use mod_rewrite for ignore case handling:

RewriteRule ^folder/heythere\.html$ http://www.newsite.com [R=301,NC,L]

Due to presence of NC flag (no case) here it will redirect both /folder/HeyThere.html and /folder/heythere.html to newsite.

7
  • The syntax provided in your answer doesn't seem to be taking effect... for lower case or uppercase
    – RCNeil
    Feb 12, 2014 at 7:05
  • Did you place RewriteEngine On before my rule? btw this should be placed in DocumentRoot/.htaccess not inside /folder/.htaccess
    – anubhava
    Feb 12, 2014 at 7:09
  • Indeed. I placed this rule after multiple after Rewrite Engine On and multiple working 301 Redirect rules. In the root. Could there be another rule conflicting with this?
    – RCNeil
    Feb 12, 2014 at 7:11
  • Make this rule your very first rule after RewriteEngine On and test in a new browser to avoid 301 caching issues.
    – anubhava
    Feb 12, 2014 at 7:12
  • Syntax looks like this RewriteEngine On RewriteBase / RewriteRule ^folder/heythere\.html$ http://www.newsite.com [R=301,NC,L] and it still doesn't work. Old browser, new browser, cleared cached...
    – RCNeil
    Feb 12, 2014 at 7:15
0

You can use regular expression with RedirectMatch for create dynamic rules.

RedirectMatch 301 /folder/(?i)HeyThere.html http://www.newsite.com

(?i) is used for case insensitivity for next characters.

I hope this will work for you :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.