Web Hosting Talk







View Full Version : Yet another subdomain/mod_rewrite question


jevon
08-28-2002, 12:08 PM
Hey, I will cut out the garbage and make this a short q.

I want any subdomain (ie. asdf.mydomain.com) to just serve up from the account i have created for "mydomain.com"...

I am doing this because I will capture the subdomain that the user is requesting and us PHP to serve up the appropriate stuff.. (I'm sure there are better ways, but I need to take this approach)...

I have been trying to do this, but I would like to get some feedback before I restart apache yet again...

Any ideas?

blacknight
08-28-2002, 12:49 PM
Maybe I'm really tired, but I didn't quite understand your question.

Do you want the sub-domains to redirect to a directory of your main site?

jevon
08-28-2002, 12:52 PM
No,. I want the subdomain to pretty much just act dumb and be an alias for the main domain..

blacknight
08-28-2002, 12:53 PM
Ok, so I understood the query, but can't understand the 'why'

elsmore1
08-28-2002, 12:53 PM
Originally posted by jevon
Hey, I will cut out the garbage and make this a short q.

I want any subdomain (ie. asdf.mydomain.com) to just serve up from the account i have created for "mydomain.com"...

I am doing this because I will capture the subdomain that the user is requesting and us PHP to serve up the appropriate stuff.. (I'm sure there are better ways, but I need to take this approach)...

I have been trying to do this, but I would like to get some feedback before I restart apache yet again...

Any ideas?

It sounds like what you really want to do is wildcard the ServerAlias in httpd.conf....

<VirtualHost ddd.ddd.ddd.ddd>
...
ServerName mydomain.com
ServerAlias *.mydomain.com
....
</VirtualHost>

jevon
08-28-2002, 01:09 PM
blacknight: That's why I told you not to worry about the why.

jevon
08-28-2002, 02:30 PM
elsmore, anyone:

That works great, but now PHP doesn't tell me the proper domain (I suspect this is apache). It only reports the ServerName setting in $SERVER_NAME.. if I set the ServerName to "www.cnn.com" and then goto http://myplace.mydomain.com , It reports www.cnn.com as the servername.. I want to find out what the actual requesting domain is.. (myplace.mydomain.com)...

Any ideas?

elsmore1
08-28-2002, 02:34 PM
The host name used in the request is in the HTTP_HOST environment variable, not in the SERVER_NAME one.