K
K
Kornely2022-01-08 18:04:32
htaccess
Kornely, 2022-01-08 18:04:32

How to create an exception in a subdomain redirect?

Previously, there was a redirect from all subdomains to the main site, since there were no subdomains.
Created a subdomain one . We created a rule for it: !^one\.site\.ru$
But all the same, the redirect also continues to go from it:

RewriteCond %{HTTP_HOST} ^(.+)\.site\.ru$
RewriteCond %{REQUEST_URI} !^one\.site\.ru$
RewriteRule (.*) https://site.ru/$1 [R=301,L,QSA]
Where is the mistake? Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2022-01-08
@Korneliy

RewriteCond %{HTTP_HOST}  !^one\.site\.ru$
RewriteCond %{HTTP_HOST} ^(.+)\.site\.ru$
RewriteRule (.*) https://site.ru/$1 [R=301,L,QSA]

http:- HTTP_HOST | https | SERVER_PORT - there are about 30 options, and not all of them work on all servers
site.ru- HTTP_HOST REQUEST_URI - QUERY_STRING Also, do not forget that .htaccess is read from top to bottom in a cycle until the urls are completely fixed, therefore special cases should be higher than general ones
/lalala/lalala.php
?id=3343

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question