Forward htaccess subdomain subdomain to new domain

One of my sites I want to redirect to another domain.

Situation:

[old] * .example.com [new] * .example.net

now i have it in my htaccess

#RewriteCond %{HTTP_HOST} ^(.*).allwebsitestats.com [NC] #RewriteRule ^(.*)$ http://$1.allwebsitestats.nl [R=301,L] 

The result of this:

The query [old] * .example.com leads to [new] .example.net, the problem is that it does not receive a substitution subdomain with it.

Thank you!

Regards, Nick

+2
source share
1 answer

Include mod_rewrite and .htaccess through httpd.conf , and then put this code in .htaccess in the DOCUMENT_ROOT directory:

 Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^(.+?)\.allwebsitestats\.com$ [NC] RewriteRule ^ http://%1.allwebsitestats.nl%{REQUEST_URI} [R=301,L] 
+1
source

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


All Articles