C
C
cipik7772019-02-12 20:41:50
PHP
cipik777, 2019-02-12 20:41:50

How to make a 301 redirect from large Cyrillic letters to small ones?

this helped solve the problem with latin

if(preg_match('/[A-Z]/', $_SERVER['REQUEST_URI'])) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: '.strtolower($_SERVER['REQUEST_URI']));
}

But how to solve the problem with the Cyrillic alphabet?
There are a lot of pages on the site. And many url's like this /PLAD+from+puffy.+Plush+plaid+WITHOUT+needles+and+hooks
are often created and doubles in lowercase, which is why you need to turn everything down, or somehow convert Cyrillic to Latin , and the above code will already process it.
The site is handwritten.
Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
cipik777, 2019-02-13
@cipik777

did so $x = mb_strtolower($x);
and closed all URLs with capital letters in Cyrillic from indexing.

A
Alexey Imsha, 2019-02-12
@aleximsha

Something like this:
preg_match('//u', $_SERVER['REQUEST_URI'])
use /u in order for Cyrillic to be processed correctly.
Keep a convenient service to help https://regex101.com/

V
Viktor Taran, 2019-02-13
@shambler81

this is a fairly simple redirect, but there is a small problem, the meaning of doing it is simply absent, what you propose speaks of a fundamentally not understanding the basics of SEO, and this is exactly why you are going to dealt a redirect.
And about the potential danger of this event.
THIS is not Windows for you in UNUX-like systems (and this is everything except windows) OS, the file system is case-sensitive. And if in Windows it is really the same characters at the file system level, then in Linux they are completely different.
And so
why you don’t need to do this,
because you don’t have a single case when it would interfere with the client, for example, he got to 404, which was displayed in your metrics, and the percentage of such hits is higher than 001
2. The person still has a bookmark with the old URL, and it would not be bad to give him 200 instead of 301+200 the weight through 301 is given away not all.
What can threaten.
well, at least site.ru/aaa.Jpg - jnlfcn 301 and naturally 404, for the reason described above,
and therefore you will need to exclude all directory links and files.
In fact, leaving only what the CNC site generates.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question