Reputation: 502
Need to know if this possible or not? If yes then how?
Main Domain is: abc.com
; Subdomain is: sub.abc.com
I want to redirect everything like [alphanumeric].abc.com
to abc.com
except the sub domain (sub.abc.com
).
e.g. ajf43vsfvsuvfsg.abc.com
to abc.com
; "ajfvsfvsuvfsg" doesn't exist.
Upvotes: 3
Views: 2616
Reputation: 143906
Try putting these rules in the htaccess file in your document root:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(sub\.)?abc.com$ [NC]
RewriteRule ^(.*)$ http://abc.com/$1 [L,R]
If someone types http://blah.abc.com/some/path
in their browser's URL address bar, they'll get redirected to http://abc.com/some/path
and the address in the address bar changes.
Upvotes: 1