Jump to content

How do I prevent using http://localhost/test and only using virtualHost ServerNa


bongobongo

Recommended Posts

Let say I have a subdir in webserver root called:

 

test

 

And I then create a virtualHost with :

...

...

DocumentRoot c:/www/htdocs/test

ServerName local.test.com

..

...

 

Now, is it possible to prevent anything being served using this

address:

http://localhost/test

 

I only want the site beeing accessible using:

local.test.com

 

How do I do that?

Link to comment
Share on other sites

You're thinking of the virtualhost tags.

 

On linux, this would be defined in: /etc/apache2 (or /usr/local/apache2) /conf/extra/virtualdomains

 

I assume on windows it would be something like c:\apache\conf\extra\virtualdomains.

 

These virtualhost tags help define subdomains/locations. Good luck.

 

 

Link to comment
Share on other sites

On linux, this would be defined in: /etc/apache2 (or /usr/local/apache2) /conf/extra/virtualdomains

 

This looks like some distro specifc config. Ive never seen it in any of the Linux distro's Ive used.

Link to comment
Share on other sites

Oh really?

 

Hmm, I suppost most of my apache experience is on Debian boxes. Also, you can install apps where ever you want, just like on windows. Those are the *most common* (at least I thought so!!!)

Link to comment
Share on other sites

Those are the *most common* (at least I thought so!!!)

 

Nah.. for instance, on Gentoo (my fav OS) virual hosts are placed within /etc/apache2/vhosts.d

 

While other systems Ive used use the upstream default apache config where your vhosts are actually specified within the global httpd.conf file.

 

Lots of distro's have lots of ways of going about different configs.

Link to comment
Share on other sites

Fascinating!

 

I figured once the default structure of the apache package was installed, it installed as any other app. I do understand that the httpd.conf can link to many other files, but I thought it distributed equally on all platforms.

 

Gentoo is a great OS btw ;)

Link to comment
Share on other sites

Debian and Ubuntu store apache under the following paths:

 

Only configs are placed inside:

/etc/apache2/

 

Configs for vhosts are stored in:

/etc/apache2/sites-available/virtualsite1.com

a2ensite

symlinks the above into: /etc/apache2/sites-enabled/virtualsite1.com

 

The webroot is by default in /var/www/

 

If you want multiple websites etc. I recommend making a /srv/www/ folder to hold the webroot for subdomains. e.g.

/srv/www/host1

/srv/www/host2

etc.

 

This seperates out the config files from the content files.

 

Debian setup & config of apache: http://wiki.kartbuilding.net/index.php/Apache_2_%26_SSL_-_PHP4_-_MySQL_4.1

 

-steve

Link to comment
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.