Jump to content

Archived

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

onlyican

Virtual host

Recommended Posts

Hey

This is strange

I am using Uniform server as my localhost
This uses Apache 2, php 5....

I am trying to set up a Virtual host
I started with adding this into the httpd.conf file

<VirtualHost>
DocumentRoot /www/game
Servername game.localhost
</VirtualHost>

And uncommented
NameVirtualHost *

ok

I went to game.localhost
and it goes to www root, not www/game

I also tried mygame

I deleted uniform server and re-installed it

Now
I set up game again
Still the same
BUT
mygame is still working (well going to www root)
Although
mygame is not ANYWHERE in the config file, its a clean install

so my 2 questions

one
WTF is going on with mygame virtual host, it dont exsist but it works?

2
How do I set up a virtual host to go to the folder www/game
or better
C:/game

(With Uniform Server, it created a Virtual Drive called W:/, so the full root is W:/www/)

HELP me please

Share this post


Link to post
Share on other sites
I think you could try to put those folders where you want it to appear. And it may appear because you havent deleted your Cache files

Share this post


Link to post
Share on other sites
oldmanice, stop spamming the apache forums, I don't think you've really helped anyone.

Take a look at this link:
http://httpd.apache.org/docs/2.0/vhosts/name-based.html

First off, you aren't using the wildcard in your virtual host directive (<VirtualHost *:80>). Also, when using name-based virtual hosting, a virtual host needs to be created for your original name and documentroot. The virtual hosts will inherit all other settings from the parent directives.

Make sure you are restarting your server everytime you make a change to the httpd config file.

I've never tested sub-domains on the localhost, but I guess if the URI isn't throwing errors that it works. You might also want to add an alias to the VH, something like this:

<VirtualHost *:80>
ServerName game.localhost
ServerAlias game.127.0.0.1  # Not sure if this would work
DocumentRoot /www/game
</VirtualHost>

Good Luck, hope this helps.

Share this post


Link to post
Share on other sites
R_P I have helped people Look at the post Unable to access outside local machine. Man chill out

Share this post


Link to post
Share on other sites
[quote author=oldmanice link=topic=104744.msg428055#msg428055 date=1157407417]
I think you could try to put those folders where you want it to appear. And it may appear because you havent deleted your Cache files
[/quote]

Read:
I deleted the localhost server, (including apache)

Deleted Cache cookies the works

and yes, I did try to enter files into the folder,
going to that address would always go to the root of the site, not the folder.

[quote author=R_P link=topic=104744.msg428480#msg428480 date=1157468480]
oldmanice, stop spamming the apache forums, I don't think you've really helped anyone.

Take a look at this link:
http://httpd.apache.org/docs/2.0/vhosts/name-based.html

First off, you aren't using the wildcard in your virtual host directive (<VirtualHost *:80>). Also, when using name-based virtual hosting, a virtual host needs to be created for your original name and documentroot. The virtual hosts will inherit all other settings from the parent directives.

Make sure you are restarting your server everytime you make a change to the httpd config file.

I've never tested sub-domains on the localhost, but I guess if the URI isn't throwing errors that it works. You might also want to add an alias to the VH, something like this:

<VirtualHost *:80>
ServerName game.localhost
ServerAlias game.127.0.0.1  # Not sure if this would work
DocumentRoot /www/game
</VirtualHost>

Good Luck, hope this helps.
[/quote]

I am not bothered about the sub domain
I saw my friend do it that way, so I was trying that

I will look at the link tomorrow, (if I have 5 mins)
Thanks

Share this post


Link to post
Share on other sites
I have added this code
[code]
NameVirtualHost *

<VirtualHost *:80>
ServerName game.localhost
ServerAlias game.127.0.0.1
DocumentRoot /www/game
</VirtualHost>
[/code]

I created a folder in /www called "game"

I put an index.php file in there

Restarted Apache 2.0

Went to
game.localhost

and it comes up with the directory of www/

So no joy

I have tried changing
DocumentRoot /www/game
to
DocumentRoot /www/game/

but the same thing happens

Share this post


Link to post
Share on other sites
try adding both (create a virtual host also for your original server name. Again, I've never seen a sub-domain construct work on a localhost. For me your breaking new territory. Good Luck.

[code]

<VirtualHost *:80>
  ServerName localhost
  ServerAlias 127.0.0.1
  DocumentRoot /www/
</VirtualHost>

<VirtualHost *:80>
  ServerName game.localhost
  ServerAlias game.127.0.0.1
  DocumentRoot /www/game/
</VirtualHost>

[/code]

Share this post


Link to post
Share on other sites
I found out why although I deleted apache, the virtual host names are still working
I am using Windows
In the folder
C:\WINDOWS\system32\drivers\etc
There is a file called
hosts (no extension)

This is the file where the info is stored

Share this post


Link to post
Share on other sites
See, I'm still not sure if using subdomains on localhost is breaking the protocol. Either way, the host file should already contain the entry:

127.0.0.1    localhost

Maybe you may want to try:

127.0.0.1    game.localhost

Keep in mind that if you go public with the server, you create subdomains at the DNS level, and manage them at the apache level - you won't need to modify the host file, ever. Glad you gained some ground. Keep on truckin.

Share this post


Link to post
Share on other sites

×

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.