vhost returns 404 [solved]

Problems with the Windows version of XAMPP, questions, comments, and anything related.

vhost returns 404 [solved]

Postby madpotter » 16. December 2012 06:00

Hi all

I"m using xampp 1.8.1 and i have a problem in configuring my vhosts in apache :roll:
But before that, I'm using windows 7 and i created first a dummy webpage so that I check if there are errors in the vhosts since Im new to xampp :?

These are the things that I did:

1. I created the hosts file in C:\Windows\System32\drivers\etc\hosts and i named my dummy website "works.localhost.dev"

Code: Select all
127.0.0.1 works.localhost.dev


2. I created the configuration in the vhosts file in C:\xampp\apache\conf\extra\httpd-vhosts.conf

here's the code:

Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot  "C:/xampp/htdocs/itworks"
    ServerName works.localhost.dev
    ServerAlias works.localhost.dev
    <Directory "C:/xampp/htdocs/itworks">
        AllowOverride All
        Allow from All
    </Directory>
</VirtualHost>


4. Lastly, I saved it and restart the apache

but when I input this dummy url on my browser, it directs me to 404 error saying that object not found. :? I've check the configurations on my system, it seems I configure it correctly. I also tried to google on how to configure vhosts the right way but unfortunately, I doesnt resolve it. I am struggling from frustration for 5 days just to figure the problem

lastly I check the error.log of apache, i cant resolve it since im a new user of xampp.

kindly check the error:

Code: Select all
[Sun Dec 16 12:39:07.600668 2012] [core:warn] [pid 2076:tid 220] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Sun Dec 16 12:39:08.167700 2012] [ssl:warn] [pid 2076:tid 220] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun Dec 16 12:39:08.240704 2012] [mpm_winnt:notice] [pid 2076:tid 220] AH00455: Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7 configured -- resuming normal operations
[Sun Dec 16 12:39:08.240704 2012] [mpm_winnt:notice] [pid 2076:tid 220] AH00456: Server built: Aug 18 2012 12:41:37
[Sun Dec 16 12:39:08.240704 2012] [core:notice] [pid 2076:tid 220] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Sun Dec 16 12:39:08.243705 2012] [mpm_winnt:notice] [pid 2076:tid 220] AH00418: Parent: Created child process 4184
AH00548: NameVirtualHost has no effect and will be removed in the next release C:/xampp/apache/conf/extra/httpd-vhosts.conf:20
[Sun Dec 16 12:39:10.457831 2012] [ssl:warn] [pid 4184:tid 232] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun Dec 16 12:39:10.528835 2012] [mpm_winnt:notice] [pid 4184:tid 232] AH00354: Child: Starting 150 worker threads.


I wish you can help me. to resolve this. Sorry the bad English. :oops:
madpotter
 
Posts: 3
Joined: 15. December 2012 08:04
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: vhost returns 404

Postby Altrea » 16. December 2012 17:24

Hi madpotter,

madpotter wrote:here's the code:

Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot  "C:/xampp/htdocs/itworks"
    ServerName works.localhost.dev
    ServerAlias works.localhost.dev
    <Directory "C:/xampp/htdocs/itworks">
        AllowOverride All
        Allow from All
    </Directory>
</VirtualHost>


Instead of this, maybe you want to try this:
Code: Select all
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
    ErrorLog "logs/localhost.error.log"
    CustomLog "logs/localhost.access.log" combined
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/itworks"
    ServerName works.localhost.dev
    ErrorLog "logs/works.localhost.dev.error.log"
    CustomLog "logs/works.localhost.dev.access.log" combined
    <Directory "C:/xampp/htdocs/itworks">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>


Changes:
  • get rid of the NameVirtualHost line. Thats old syntax
  • get rid of the ServerAlias, if it is the same as the ServerName
  • changing to new access syntax => viewtopic.php?f=16&t=50985
  • adding a default VHost for localhost, the orange XAMPP administration page
  • Adding Access and Error logs for each VHost

last thing: make sure the DocumentRoot directory exists.

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6942
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: Windows 10 Pro x64

Re: vhost returns 404

Postby madpotter » 17. December 2012 06:44

Thank you for the reply

I got rid of the NameVirtualHost, serveralias, added the changes in the hosts and also and follow your codes which you wrote but still its getting a 404 error page. I forgot to mention yesterday about my location of my directory of this site "works.localhost.dev" its in C:\xampp\htdocs\itworks also i input this in my url "localhost/works.localhost.dev". my bad

It looks like some codes in apache are deprecated, So this is the reason why my vhosts is not working.. but still my vhost doesnt recognize my dummy url. any idea?

here's the code I've followed and host file:

Code: Select all
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
    ErrorLog "logs/localhost.error.log"
    CustomLog "logs/localhost.access.log" combined
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/itworks"
    ServerName works.localhost.dev
    ErrorLog "logs/works.localhost.dev.error.log"
    CustomLog "logs/works.localhost.dev.access.log" combined
    <Directory "C:/xampp/htdocs/itworks">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>


for host file:

Code: Select all
127.0.0.1 localhost

127.0.0.1 works.localhost.dev


Thank you
madpotter
 
Posts: 3
Joined: 15. December 2012 08:04
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: vhost returns 404

Postby Altrea » 17. December 2012 16:39

madpotter wrote:i input this in my url "localhost/works.localhost.dev". my bad

Thats the wrong url. http://works.localhost.dev/ would be correct

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6942
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: Windows 10 Pro x64

Re: vhost returns 404

Postby madpotter » 18. December 2012 04:11

THANK YOU.. YOUR MY HERO!! IT WORKED!! =D
madpotter
 
Posts: 3
Joined: 15. December 2012 08:04
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: vhost returns 404

Postby Altrea » 18. December 2012 05:31

You are welcome :D
Have fun with XAMPP and all that crazy stuff 8)
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6942
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: Windows 10 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: rjian001 and 65 guests