Apache.htaccess redirects subdomain to parent domain

I want to redirect my subdomain

http://xyz.domain.com at http://domain.com

and similarly any subdirectories such as

http://xyz.domain.com/abc at http://domain.com/abc

I do not want redirects for all of my subdomains, but specifically for this.

thanks for the help

+3
source share
2 answers
RewriteCond %{HTTP_HOST} ^xyz\.domain\.com$
RewriteRule ^/(.*) http://domain.com/$1 [redirect,last]
+5
source

The easiest way to redirect a subdirectory to a domain:

RedirectMatch 301 ^/subdir/$  http://example.com$1
0
source

Source: https://habr.com/ru/post/1792157/


All Articles