There is a link www.lb.domen.ru which opens through .htaccess the page /company/domen.php?ELEMENT_ID=69324

RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.lb\.domen\.ru$ RewriteCond %{REQUEST_URI} ^/ RewriteRule ^(.*)$ company/domen.php?ELEMENT_ID=69324 

how to make a redirect correctly if it goes to www.lb.domain.ru/company/ or another link, i.e. you only need one page for the domain www.lb.domen.ru, others should be redirected to the main domain.

 пробую так, не работает RewriteCond %{REQUEST_URI} !^/ RewriteRule ^(.*)$ http://domen.ru$ [L,R=301] 

    1 answer 1

    Try this:

     RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.lb\.domen\.ru$ RewriteCond %{REQUEST_URI} ^\/?$ RewriteRule .* company/domen.php?ELEMENT_ID=69324 [L] RewriteCond %{HTTP_HOST} ^www\.lb\.domen\.ru$ RewriteCond %{QUERY_STRING} !^ELEMENT_ID=69324$ [OR] RewriteCond %{REQUEST_URI} !^\/company\/domen.php$ RewriteRule .* http://domen.ru? [L,R=301] 
    • No, it does not work ... - kotdg
    • @kotdg, rewriteCond RewriteCond %{REQUEST_URI} !^\/company\/domen.php$ changed, the company directory was not registered. On a local host checked, works. - Visman
    • for sure) works, thanks - kotdg