Answer the question
In order to leave comments, you need to log in
What is the correct way to write a negated regex for .htaccess?
The site has different localizations for different countries. They look like this:
example.com/ar
example.com/es
example.com/it
example.com/ru
and 10 more pieces
You need to make a redirect for all locales, excluding two of them. That is, with / ar and / es redirect is not needed.
How do I do
RewriteCond %{REQUEST_URI} !(^/(ar|es))
RewriteRule .* http://example.com/some_page.html [R=302,L]
Answer the question
In order to leave comments, you need to log in
In general, you are wrong, because with 10 sites it is really easier to make an inclusion than an exclusion by 3 letters, the probability of falling into this range is too high. Also, in the beginning, there is no slash in Uri, and therefore it does not work.
also don't forget about case insensitivity
RewriteCond %{REQUEST_URI} ^(it|ru|com|kz|ua) [NC]
RewriteRule ^.*$ http://%{SERVER_NAME}/some_page.html [R=301,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question