directory
directory

Reputation: 3167

Subdomain wildcard htaccess redirection to new domain

One of my websites I want to redirect o another domain.

The situation:

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

for now I have this in my htaccess

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

The result of this;

Request [old] *.example.com results in [new] .example.net, the problem is it doesn't get the wildcard subdomain with it.

Thanks you!

Regards, Nick

Upvotes: 3

Views: 8403

Answers (1)

anubhava
anubhava

Reputation: 786011

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under 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]

Upvotes: 4

Related Questions