Wildcard Subdomain to Domain

Using a single web hosting account to host multiple sites

Wildcard Subdomain to Domain

Postby benoka » Sat Aug 08, 2009 11:13 am

Hi,

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!
benoka
 
Posts: 23
Joined: Fri Jun 19, 2009 9:23 am

Postby richardk » Wed Aug 12, 2009 10:46 am

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

The GoDaddy hosting needs to be set to send the sub domain requests to the same place as your main domain. It sounds like it is not and is just sending a 403 (not your 403, a general server 403).

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):

Remove the sub domain mod_rewrite until you stop getting a 403 error.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby benoka » Thu Aug 13, 2009 12:16 am

richardk, first of all, thank you for your help!

The GoDaddy hosting needs to be set to send the sub domain requests to the same place as your main domain.

well, yes, this would be the wildcard subdomain redirection I'm looking for, but there's no such option in GoDaddy hosing. I tried to setup a subdomain called "*" but it didn't allow me (only letters and numbers allowed).

Remove the sub domain mod_rewrite until you stop getting a 403 error.

i removed the one redirection (if this is what you meant) I had in there, so my code looked like this:

Code: Select all
ErrorDocument 404 http://maindomain.de/404.html
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.maindomain\.de [NC]
RewriteCond %{HTTP_HOST} ^((www\.)?([a-z]+)\.)maindomain\.de [NC]
RewriteRule .? http://maindomain.de [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [L]

but unfortunately this didn't help.

I'm only getting the 403 error if I try to look for a subdomain that doesn't exist. If you meant I should setup the wildcard at godaddy and remove the sub domain mod_rewrite after, well, yeah, for that I'd need to know how to setup wildcard subdomain in godaddy... :)

thank you for your help in advance.
benoka
 
Posts: 23
Joined: Fri Jun 19, 2009 9:23 am

Postby richardk » Fri Aug 14, 2009 12:47 pm

well, yes, this would be the wildcard subdomain redirection I'm looking for, but there's no such option in GoDaddy hosing. I tried to setup a subdomain called "*" but it didn't allow me (only letters and numbers allowed).

You probably can't do it then, you'd have to ask GoDaddy about it.

Mod_rewrite in a .htaccess file only gets processed when the request gets to that directory (that the .htaccess file is in). So, if the sub domains all fail (403 error) when they get to the server because the server doesn't know where to send them (because you haven't set up a sub domain -> document root for them) the mod_rewrite is not processed.

i removed the one redirection (if this is what you meant) I had in there, so my code looked like this:

I meant all Rewrite* lines for the sub domain.

Without the sub domain code
Code: Select all
ErrorDocument 404 /404.html

Options +FollowSymLinks

Redirect 301 /blog http://maindomain.blogspot.com
Redirect 301 /blog.html http://maindomain.blogspot.com

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME}.html -f
RewriteRule ^(.+)$ /$1.html [L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby benoka » Sat Aug 15, 2009 1:00 am

Mod_rewrite in a .htaccess file only gets processed when the request gets to that directory (that the .htaccess file is in). So, if the sub domains all fail (403 error) when they get to the server because the server doesn't know where to send them (because you haven't set up a sub domain -> document root for them) the mod_rewrite is not processed.

So this means that even though the registrar sends all subdomain requests to the IP address of my hosting server, the hosting server doesn't recognize that request, right? Now, to trick this, I tried to setup the .htaccess file with the subdomain redirection on the main domain of my shared hosting (supposing that the registrar wildcard redirection ends up there), but it gave the same 403 error - so the request doesn't even get to the main folder of my primary domain (also tried with a rubbish .htaccess file, same thing, 403 error instead of 500).

So, let me e-mail GoDaddy and find out what can be done.

Thank you for your help so far!
benoka
 
Posts: 23
Joined: Fri Jun 19, 2009 9:23 am

Postby benoka » Sun Aug 16, 2009 11:04 pm

The e-mail from GoDaddy:
I understand that you would like to setup a wild card DNS so that all sub domains go to a specific location within your hosting account. Unfortunately this is unable to be setup within our hosting accounts. I apologize for any inconvenience this may cause.

So, if I de-activate wildcard subdomain at my registrar and setup a .htaccess at my GoDaddy hosting primary domain, do you think it will work? Or I just have to give up or upgrade my hosting plan?
benoka
 
Posts: 23
Joined: Fri Jun 19, 2009 9:23 am

Postby richardk » Tue Aug 18, 2009 3:48 pm

So, if I de-activate wildcard subdomain at my registrar and setup a .htaccess at my GoDaddy hosting primary domain, do you think it will work?

That will not work.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby benoka » Tue Aug 18, 2009 9:29 pm

A 2nd reply came from GoDaddy with this information:
...If you were to add a Dedicated IP address to your hosting account, the Wildcard for your sub domains would work.

Dedicated IP at GoDadddy: 2 months 2.99 USD, not bad, will think about it...

Anyways, thank you richardk a millions for your kind help!

I wish you all the best!
benoka
 
Posts: 23
Joined: Fri Jun 19, 2009 9:23 am


Return to Domain Handling

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

cron