Azu Posted August 24, 2007 Share Posted August 24, 2007 Hi, I've been using modrewrites to basically have sections like website.com/Forum website.com/Forum but I don't really like this. How can I change it to use like forum.website.com help.website.com instead? Quote Link to comment https://forums.phpfreaks.com/topic/66460-subdomains/ Share on other sites More sharing options...
keeB Posted August 24, 2007 Share Posted August 24, 2007 Look in the httpd-virtualdomains.conf file Quote Link to comment https://forums.phpfreaks.com/topic/66460-subdomains/#findComment-332749 Share on other sites More sharing options...
Azu Posted August 24, 2007 Author Share Posted August 24, 2007 Sorry I meant how can I do this in PHP itself? Not something specific to certain web servers. Quote Link to comment https://forums.phpfreaks.com/topic/66460-subdomains/#findComment-332754 Share on other sites More sharing options...
trq Posted August 24, 2007 Share Posted August 24, 2007 Look in the httpd-virtualdomains.conf file That is a distro specific file, not that of any default apache conf. Sorry I meant how can I do this in PHP itself? Not something specific to certain web servers. It is a webserver specific setting and needs to be handled well before any php processing. In Apache there are two ways of doing it. You can either create a new vhost, this requires a server restart, or, the easier way is to use your .htaccess file. For each subdomain you would need to add something simular to.... RewriteCond %{HTTP_HOST} sub.domainname.com$ RewriteCond %{REQUEST_URI} !sub/ RewriteRule ^(.*)$ sub/$1 to your .htaccess file, replacing sub with the relevent parts. Of course you can use PHP to write to your .htaccess file. Ive no idea how IIS handles these things though. Knowing windows you prbably need to open some gui and click some buttons. Quote Link to comment https://forums.phpfreaks.com/topic/66460-subdomains/#findComment-332770 Share on other sites More sharing options...
Azu Posted August 25, 2007 Author Share Posted August 25, 2007 Thanks guys. Isn't there some way to do it in PHP though? So that it will work on all webservers that run PHP? I would really really appreciate that ^^ Quote Link to comment https://forums.phpfreaks.com/topic/66460-subdomains/#findComment-334131 Share on other sites More sharing options...
pkSML Posted August 25, 2007 Share Posted August 25, 2007 I don't know if that would be possible. PHP is invoked by the webserver after it has received a request for a file associated with the PHP parser. ***But***, for the server to answer the call, there must a valid host for which that server is set up to answer to (unless it is a default host). So by asking for forums.website.com, the server must have a host set up for this subdomain, otherwise all requests will be ignored. Try giving some more information about your setup, possible even the real URL. The more info given, the better chance you can be helped if there is a solution. BTW, the best servers out there perform this feature, so you're not excluding anybody by using server-level URL rewriting. Quote Link to comment https://forums.phpfreaks.com/topic/66460-subdomains/#findComment-334150 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.