Apache cannot access to my localhost php webpage

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

Apache cannot access to my localhost php webpage

Postby HTHVampire » 02. August 2015 15:30

Hi,

When I try to enter localhost/uccn3004, I got an error 404. I already set up virtual host for my webpage and I'm able to access it using www.empire.com(virtual host name I created) but not for localhost/uccn3004. Besides that, my localhost/phpmyadmin also working fine.

Here's my configuration details:

1. My directory for htdocs and all my websites are stored in UCCN3004 folder
Image

2. My document root setting
Even I try to change the path to C:/xampp/htdocs/UCCN3004, it doesn't work as well.
Image

3. vhosts configuration
Image

4. Error found
Image

Can someone figure out any problems with my setting? Thank you very much!
HTHVampire
 
Posts: 4
Joined: 02. August 2015 15:16
Operating System: Windows 8.1

Re: Apache cannot access to my localhost php webpage

Postby JJ_Tagy » 02. August 2015 16:49

Looking at your file structure, it is in UCCN3004 instead of uccn3004. Perhaps try to match the case?
JJ_Tagy
 
Posts: 678
Joined: 30. January 2012 13:44
Operating System: Windows 10 Pro x64

Re: Apache cannot access to my localhost php webpage

Postby HTHVampire » 02. August 2015 17:20

JJ_Tagy wrote:Looking at your file structure, it is in UCCN3004 instead of uccn3004. Perhaps try to match the case?


Hi, thanks for the suggestion, I tried but it still can't access.
HTHVampire
 
Posts: 4
Joined: 02. August 2015 15:16
Operating System: Windows 8.1

Re: Apache cannot access to my localhost php webpage

Postby JJ_Tagy » 02. August 2015 17:32

Revert back all your .conf changes and see if localhost works. Don't forget to stop/start apache. Then try UCCN3004 again. Also, do you have an index.php or similar in UCCN3004?
JJ_Tagy
 
Posts: 678
Joined: 30. January 2012 13:44
Operating System: Windows 10 Pro x64

Re: Apache cannot access to my localhost php webpage

Postby Nobbie » 02. August 2015 18:47

When you specify even only ONE VirtualHost, all standard settings (outside from VirtualHosts) are IGNORED by Apache. instead, you *should* specify a VirtualHost for localhost as well (similar to your declaration for empire.com).

If you DO NOT specify a VirtualHost for localhost, Apache does NOT take the "external" settings of your ServerName etc., instead Apache simply takes the FIRST VirtualHost of your declared VirtualHosts. In your case, if you enter "localhost", Apache does not know that is meant by that and takes your first VirtualHost, and this the declaration of empire.com.

And the DocumentRoot of empire.com is NOT c:/xampp/htdocs - and therefore http://localhost/UCCN3004 yields to c:/xampp/htdocs/UCCN3004/UCCN3004 (you see, what is going wrong?!) and of course, Apache cannot find that. Instead, if you only enter http://localhost, this *should* show up your empire.com Host, and that yields to DocumentRoot c:/xampp/htdocs/UCCN3004

Try it and you will see, simply http://localhost will show your UCCN3004 files. Probably you dont want this behaviour, therefore add another VirtualHost for ServerName localhost and apply DocumentRoot c:/xampp/htdocs.
Nobbie
 
Posts: 8770
Joined: 09. March 2008 13:04

Re: Apache cannot access to my localhost php webpage

Postby HTHVampire » 02. August 2015 19:03

Nobbie wrote:When you specify even only ONE VirtualHost, all standard settings (outside from VirtualHosts) are IGNORED by Apache. instead, you *should* specify a VirtualHost for localhost as well (similar to your declaration for empire.com).

If you DO NOT specify a VirtualHost for localhost, Apache does NOT take the "external" settings of your ServerName etc., instead Apache simply takes the FIRST VirtualHost of your declared VirtualHosts. In your case, if you enter "localhost", Apache does not know that is meant by that and takes your first VirtualHost, and this the declaration of empire.com.

And the DocumentRoot of empire.com is NOT c:/xampp/htdocs - and therefore http://localhost/UCCN3004 yields to c:/xampp/htdocs/UCCN3004/UCCN3004 (you see, what is going wrong?!) and of course, Apache cannot find that. Instead, if you only enter http://localhost, this *should* show up your empire.com Host, and that yields to DocumentRoot c:/xampp/htdocs/UCCN3004

Try it and you will see, simply http://localhost will show your UCCN3004 files. Probably you dont want this behaviour, therefore add another VirtualHost for ServerName localhost and apply DocumentRoot c:/xampp/htdocs.


Hi Nobbie, I appreciate your help, since I'm still new to Apache, I truly appreciate the concepts you delivered here and finally I manage to get what I need. Thank you very much! same goes to HH_Tagy that tried to help, thank you.
HTHVampire
 
Posts: 4
Joined: 02. August 2015 15:16
Operating System: Windows 8.1

Re: Apache cannot access to my localhost php webpage

Postby Nobbie » 02. August 2015 19:20

Finally, if you wonder why phpmyadmin works...

HTHVampire wrote:Besides that, my localhost/phpmyadmin also working fine.


... (as it should not work, due to the concepts explained before); the URL /phpmyadmin is not related to c:/xampp/htdocs/UCCN3004/phpmyadmin (this is, what you would expect now), because /phpmyadmin is overriden by a so called "ALIAS". See the documentation about ALIAS and you will find appropriate declaration in extras/httpd-xampp.conf (i am not 100% sure about that, but you will find out, where it is). ALIAS is kind of "special DocumentRoot" for a single URL (or virtual folder). The ALIAS is a very helpfully configuration, if you need to apply a document, what "normally" is outside of the scope of DocumentRoot.
Nobbie
 
Posts: 8770
Joined: 09. March 2008 13:04

Re: Apache cannot access to my localhost php webpage

Postby HTHVampire » 02. August 2015 21:14

Hi Nobbie,

Thanks for the further details explained. I learnt much from you, really appreciate your time to deal with my problem. Thank you!
HTHVampire
 
Posts: 4
Joined: 02. August 2015 15:16
Operating System: Windows 8.1


Return to XAMPP for Windows

Who is online

Users browsing this forum: hthnightwolf, JJ_Tagy and 63 guests