L
L
ljutaev2018-09-06 08:30:09
htaccess
ljutaev, 2018-09-06 08:30:09

How do I set up a redirect from an uppercase URL to their corresponding lowercase URL?

How do I set up a redirect from an uppercase URL to their corresponding lowercase URL?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2018-09-06
@ljutaev

Since Apache 2.4 https://httpd.apache.org/docs/2.4/expr.html#functions

RewriteCond expr "tolower(%{REQUEST_URI}) =~ /(.+)/"
RewriteRule [A-Z] %1 [R=301,L]

A
Alexander, 2019-11-12
@alek-sandr

This code (it is taken from the address given by Vasily Pupkin ):

<IfModule mod_speling.c>
CheckCaseOnly On
CheckSpelling On
</IfModule>
redirects the entire URL, addresses of secondary pages too.
And the code dodo512 redirects only the main URL, without secondary pages.
If the secondary address is also in uppercase, then it sends to 404-error - this is certainly better than duplicate pages with addresses in different registers, but in my opinion a 301 redirect is better.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question