A
A
Alexey Khoroshevsky2020-03-13 11:02:17
Apache HTTP Server
Alexey Khoroshevsky, 2020-03-13 11:02:17

How to set up 301 redirect from uppercase to lowercase only for pseudo-directories (multi-language site)?

Hello. Site on Joomla 3. added the following code to .htaccess:

RewriteEngine On
RewriteBase /
# If there are caps, set HASCAPS to true and skip next rule
RewriteRule [AZ] - [E=HASCAPS:TRUE,S=1]
# Skip this entire section if no uppercase letters in requested URL
RewriteRule ![AZ] - [S=28]
# Replace single occurance of CAP with cap, then process next Rule.
RewriteRule ^([^A]*)A(.*)$ $1a$2
RewriteRule ^([^B]*)B(.*)$ $1b$2
RewriteRule ^([^C]*)C(.*) $ $1c$2
RewriteRule ^([^D]*)D(.*)$ $1d$2
RewriteRule ^([^E]*)E(.*)$ $1e$2
RewriteRule ^([^F]*)F (.*)$ $1f$2
RewriteRule ^([^G]*)G(.*)$ $1g$2
RewriteRule ^([^H]*)H(.*)$ $1h$2
RewriteRule ^([^I]*)I(.*)$ $1i$2
RewriteRule ^([^J]*)J(.*) $ $1j$2
RewriteRule ^([^K]*)K(.*)$ $1k$2
RewriteRule ^([^L]*)L(.*)$ $1l$2
RewriteRule ^([^M]*)M (.*)$ $1m$2
RewriteRule ^([^N]*)N(.*)$ $1n$2
RewriteRule ^([^O]*)O(.*)$ $1o$2
RewriteRule ^([^P ]*)P(.*)$ $1p$2
RewriteRule ^([^Q]*)Q(.*)$ $1q$2
RewriteRule ^([^R]*)R(.*)$ $1r$2
RewriteRule ^ ([^S]*)S(.*)$ $1s$2
RewriteRule ^([^T]*)T(.*)$ $1t$2
RewriteRule ^([^U]*)U(.*)$ $1 u$2
RewriteRule ^([^V]*)V(.*)$ $1v$2
RewriteRule ^([^W]*)W(.*)$ $1w$2
RewriteRule ^([^X]*)X(. *)$ $1x$2
RewriteRule ^([^Y]*)Y(.*)$ $1y$2
RewriteRule ^([^Z]*)Z(.*)$ $1z$2
# If there are any uppercase letters, restart at very first RewriteRule in file.
RewriteRule [AZ] - [N] RewriteCond % {
ENV:HASCAPS} TRUE RewriteRule ^
/?(.*) /$1 [R=301,L] works fine. But for the URL of the Russian version ( https://site.ua/ru/proeKTY) and the English version (https://site.ua/en/projeCTS ) it gives a server error 500 (Internal Server Error. Error in the site settings. Most likely, this the error occurred due to incompatible .htaccess settings).


What needs to be written in order for these rules to work for pseudo-directories as well? Thanks in advance for your reply.

PS This is a task from the list from an SEO specialist. Personally, I would not do it, but alas, it is necessary.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2020-03-13
@shambler81

NO WAY! Let me guess, this is what the SEO suggested?
so spit in his face.
Firstly, this does not affect SEO in any way.
Secondly, linux is a case-sensitive OS, unlike windows, you cannot take it and simply omit the case.
if you have a file
Images.jpg
images.jpg
images.JPG
These are completely different files at the file system level.
The same with CNC, not the fact that your engine is case-independent, rather the opposite.
In short, such a hat is recommended by people who simply do not understand how a web server works at all.
Also a very strange hat is this
RewriteRule [AZ] - [N]
RewriteCond %{ENV:HASCAPS} TRUE
RewriteRule ^/?(.*) /$1 [R=301,L]
What were you trying to do with it?
So I'm trying to somehow understand each line and I don't understand
RewriteRule [AZ] - [N] - he will go to the next round without you, moreover, L won't stop him, I'm not even talking about the fact that 1 letter of the upper register and everything, for example site.ru/S
RewriteCond %{ENV:HASCAPS} TRUE - it's not clear why this is here at all
RewriteRule ^/?(.*) /$1 [R=301,L] - GET parameter is not part of the url in principle, and RewriteRule can not see it at all!
if you wanted to remove all get parameters then do it somehow like this RewriteRule - /$0? [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question