La regla de redirección .htaccess 301 no funciona debido a las letras mayúsculas

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.

Esto no funciona:

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

pero esto lo hace

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?

preguntado el 12 de febrero de 14 a las 06:02

2 Respuestas

Es mejor que uses mod_rewrite for ignore case handling:

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

Debido a la presencia de NC flag (no case) here it will redirect both /folder/HeyThere.html y /folder/heythere.html to newsite.

Respondido 12 Feb 14, 06:02

The syntax provided in your answer doesn't seem to be taking effect... for lower case or uppercase - RC Neil

Pusiste RewriteEngine On before my rule? btw this should be placed in DocumentRoot/.htaccess no en el interior /folder/.htaccess - anubhava

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? - RC Neil

Make this rule your very first rule after RewriteEngine On and test in a new browser to avoid 301 caching issues. - anubhava

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... - RC Neil

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 :)

Respondido 12 Feb 14, 07:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.