I'm trying to redirect all subdomain requests to my main domain.
It's a .de domain, so it's not easy - the registrar is not very flexible and the online options they provide are kinda middle age: I can only set one A-record and my main domain is already routed to an external IP for the hosting, GoDaddy (shared).
However, the registrar has an option called 'Activate Wildcard-Subdomain' or (if activated) 'De-activate Wildcard-Subdomain'. If I have it active and try to reach a non-existing subdomain, the apache server 403 error comes up, if I have it de-activated, my DNS service search is appearing (i.e. page not found).
The .htaccess code I'm trying is (I'm including the entire code so that you can check that they don't interfere or something):
- Code: Select all
ErrorDocument 404 http://maindomain.de/404.html
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
Redirect 301 /blog http://maindomain.blogspot.com
Redirect 301 /blog.html http://maindomain.blogspot.com
RewriteCond %{HTTP_HOST} !^www\.maindomain\.de [NC]
RewriteCond %{HTTP_HOST} ^((www\.)?([a-z]+)\.)maindomain\.de [NC]
RewriteRule .? http://maindomain.de [L]
The redirection for the subdomain 'blog' is working perfectly. I tried to change the error document 403 to redirect to the error document 404 or to the main site, but it didn't work.
Any help is much appreciated.
Thanks in advance!