redirecting all subdomains to main domain

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 33
Joined: 18 Jul 2012, 07:50

redirecting all subdomains to main domain

30 Jun 2015, 09:55

I would like to redirect all the subdomains to main domain.

i.e

abc.example.com should be redirected to example.com

similarly

xyz..example.com should also be redirected to example.com

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: redirecting all subdomains to main domain

30 Jun 2015, 13:27

Hello,

It should look like this:

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

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 22 guests