Jump to content

hat work


crp

Recommended Posts

I want my CentOS server to serve up different pages depending on whether the user entered in

rh5.ex123.xyz or forum.ex123.xyz

 

rh5 to provide the files in /var/www/html

forum to provide the files in /var/www/mybb

I put the following into the httpd.conf

<VirtualHost *:80>
DocumentRoot /var/www/mybb
<Directory "/var/www/mybb">
allow from all
Options +Indexes
</Directory>
ServerName forum.ex123.xyz
</VirtualHost>

Problem is , entering forum.ex123.xyz or rh5.ex123.xyz both serve up the pages of forum.

How do I setup the configuration file so that the forum files only get served up if forum.ex123.xyz in the address in the URL ?

Link to comment
Share on other sites

You'll need to create two virtual host stanzas.

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName rh5.ex123.xyz
  <Directory /var/www/html>
    allow from all
    Options +Indexes
  </Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www/mybb
ServerName forum.ex123.xyz
  <Directory /var/www/mybb>
    allow from all
    Options +Indexes
  </Directory>
</VirtualHost>

 

Make sure the NameVirtualHost directive is uncommented if not already. The other thing to remember is that you will need to make sure you have DNS or host file entries on the client for both site name.

Link to comment
Share on other sites

oh, :hmm:

I thought that there was a default built into Apache so that if the URL name is not used but it's DNS is pointing to the pc's IP address, /var/www/html is used.

Edited by crp
Link to comment
Share on other sites

oh, :hmm:

I thought that there was a default built into Apache so that if the URL name is not used but it's DNS is pointing to the pc's IP address, /var/www/html is used.

 

I thought that too, but I think the behaviour has changed and you must explicitly put the default in a virtualhost directive. It's been a couple of years since I've set that up so if you give me some time I can verify that in my test lab.

Link to comment
Share on other sites

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.   Paste as plain text instead

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