Page 1 of 1

Subdomains with Apache

Posted: Tue Nov 14, 2006 7:34 pm
by deleet
Hello everyone. I'm using a web server with Apache and I need to redirect the users from http://username.domain.com to http://www.domain.com/view.php?u=username.

My problem right now isn't the rewrite rule, I am simply unable to open any page (as in, if I type http://randomness.domain.com I get no page at all, server not found). I called my hosting company and they told me that I had to upload a script to rewrite the URL's (which I thought mod_rewrite did?).

I also read somewhere that I need to add a DNS entry for the domain name, something like http://*.domain.com pointing to my web server's IP address. I cannot do this in my host's administration panel. The domain name is hosted with GoDaddy, am I able to do it there?

I'm not very familiar with this aspect of Apache, help would be greatly appreciated.

Thank you for your time.

Posted: Tue Nov 14, 2006 7:46 pm
by nickvd
Show us your rewrite rule.

Posted: Tue Nov 14, 2006 7:49 pm
by deleet
I don't think the rewrite is the problem but..

RewriteEngine on
rewriterule ^(.+)\.domain.com$ http://www.domain.com/view.php?u=$1 [nc]

Thanks.

Posted: Tue Nov 14, 2006 7:53 pm
by nickvd
The rule seems okay on first inspection. I re-read your post and missed something the first time around...
I also read somewhere that I need to add a DNS entry for the domain name, something like http://*.domain.com pointing to my web server's IP address. I cannot do this in my host's administration panel. The domain name is hosted with GoDaddy, am I able to do it there?
Not familiar with godaddy, but you're right, you should need a wildcard subdomain in order for foo.domain/bar.domain to resolve correctly.