Jump to content

Subdomains


Azu

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/66460-subdomains/#findComment-332770
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/66460-subdomains/#findComment-334150
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.