Localhost not working after adding first vhost
Posted by: DominikH (---.ukf.sk)
Date: September 30, 2024 10:25AM

Hi guys,

First of all, I would like to thank you for WampServer. I teach web development at a university, and WampServer is a blessing for me and my students when it comes to rapidly understanding the Apache + PHP + MariaDB ecosystem. Last week, the new semester started, and as always, we created a new application in PHP. The problem is that this year, I decided that we would not create vhosts via the config file but via the GUI provided by WampServer (http://forum.wampserver.com/read.php?2,146746). Everything was working fine until one of my students told me that he could no longer access [localhost] and was getting a 404 Not Found error. The vhost we added still works fine. I tried to fix the issue, but based on my understanding, everything looks correct.

Here is my httpd-vhosts.conf:

# Virtual Hosts
#
<VirtualHost _default_:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
#
<VirtualHost *:80>
ServerName diff-mania-be.local
DocumentRoot "c:/wamp64/www/diff-mania-be/public"
<Directory "c:/wamp64/www/diff-mania-be/public/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
#


Here is my hosts file on Windows 11:

#
127.0.0.1 localhost
::1 localhost

127.0.0.1 diff-mania-be.local
::1 diff-mania-be.local
# Added by Docker Desktop
192.168.0.102 host.docker.internal
192.168.0.102 gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section

I also used the Apache Tool shipped with WampServer to check the active vhosts, and it correctly displayed two vhosts: localhost and diff-mania-be.local. My current version of WampServer is 3.3.5. Can anybody give me some advice on how to get the localhost domain working again?

Re: Localhost not working after adding first vhost
Posted by: Otomatic (Moderator)
Date: September 30, 2024 11:09AM

Hi,

Maybe clear your browser's cache! Normally by pressing Ctrl-F5.

Or perhaps blocked by antivirus or anti-xxx software.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Re: Localhost not working after adding first vhost
Posted by: DominikH (---.ukf.sk)
Date: September 30, 2024 12:15PM

Hi Otomatic,

thank you for your quick resonse. I done everything:

1. Cleared browser DNS cache
2. Cleard Win DNS cache
3. Tried different browser
4. Restarted PC

Nothing helped.

Re: Localhost not working after adding first vhost
Posted by: Otomatic (Moderator)
Date: September 30, 2024 04:49PM

Hi,

At the Windows administrator command prompt, enter the following commands:

netsh winsock reset
netsh winsock reset proxy
netsh winsock reset tracing
netsh winsock reset catalog
netsh int ip reset all
netsh int ipv4 reset catalog
netsh int ipv6 reset catalog
ipconfig /flushdns

Then restart the machine. Be careful, this will reset the entire IP configuration.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Re: Localhost not working after adding first vhost
Posted by: DominikH (---.static.orange.sk)
Date: October 01, 2024 09:48AM

Hi Otomatic,

executed all the commands and everything was executed successfully based on the results from the command line. Unfortunately the problem remains.

Re: Localhost not working after adding first vhost
Posted by: DominikH (---.static.orange.sk)
Date: October 01, 2024 01:04PM

Hi Otomatic,

maybe it will help you information that aliases are working correctly:

[localhost]
[localhost]
[localhost]

But when I get [localhost] I am getting 404

Re: Localhost not working after adding first vhost
Posted by: Otomatic (Moderator)
Date: October 01, 2024 02:53PM

Hi,

Isn't there an .htaccess file inadvertently added to the c:/wamp64/www/ folder?

Does 'http://localhost/add_vhost.php' give the page?

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Re: Localhost not working after adding first vhost
Posted by: DominikH (---.static.orange.sk)
Date: October 01, 2024 05:35PM

Hi Otomatic,

you would not beleave but you were right. I had for some reason .htaccess in c:/wamp64/www/ with the following content:

RewriteEngine On
RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]

So it could not work at all. Sorry for the inconvinience and thank you for your help, I scan the folder with my eyes like 10 times and I could not see it. Sorry again.

Sorry, only registered users may post in this forum.