Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.