R
R
run1822018-02-12 13:43:32
htaccess
run182, 2018-02-12 13:43:32

How to make a redirect from all subdomains except one to the main one?

RewriteCond %{HTTP_HOST} ^([a-z0-9_-]+).site\.ru$ 
RewriteCond %{HTTP_HOST} !=spb.site.ru [NC]
RewriteRule ^(.*) http://site.ru/$1 [R=301,L]

Tried this code - doesn't work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2018-02-13
@shambler81

RewriteCond %{HTTP_HOST} ^.+\.site\.ru$ 
RewriteCond %{HTTP_HOST} !^spb\.site\.ru$ [NC]
RewriteCond %{HTTP_HOST} !^www\.site\.ru$ [NC]
RewriteRule ^(.*) http://site.ru/$1 [R=301,L]

www.exlab.net/files/tools/sheets/mod_rewrite/mod_r...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question