Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Viernes's avatar

Problem with Vhosts

I created a new project and set my Hosts file to

127.0.0.1       app.test

and Vhosts in Apache

##<VirtualHost *:80>
    ##ServerAdmin [email protected]
    ##DocumentRoot "C:/xampp/htdocs/test/public"
    ##ServerName app.test
    ##ErrorLog "logs/dummy-host2.example.com-error.log"
    ##CustomLog "logs/dummy-host2.example.com-access.log" common
##</VirtualHost>

The Problem when i enter app.test it redirect me to http://me.test/dashboard/ not to my laravel Project.

0 likes
18 replies
smartnathan's avatar

You didn't remove the comments there. Hence, the reason you are having that issue.

smartnathan's avatar

<VirtualHost *:80> ##ServerAdmin [email protected] DocumentRoot "C:/xampp/htdocs/test/public" ServerName app.test ##ErrorLog "logs/dummy-host2.example.com-error.log" ##CustomLog "logs/dummy-host2.example.com-access.log" common

Cronix's avatar

## are comments, remove them unless you're trying to comment the line out (so it won't get read/processed).

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "C:/xampp/htdocs/test/public"
    ServerName app.test
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
jimmck's avatar

@Viernes Are you on a Mac? You use dnsmasq and create virtual projects by just adding a vhost entry. Nothing goes in your hosts except the dnsmasq alias you create once. Homebrew has a service for dnsmasq. Works great.

Viernes's avatar

@smartnathan & @Cronix it's still the same @jimmck i use windows and i tried Acrylic DNS Proxy instead and didn't work .

the mean problem i found when i ping app.test it gives me foreign IP not 127.0.0.1

jimmck's avatar

@Viernes Hi Hmm... looked at Acrylic it forwards packets to a proxy server and routes back to local? No we don't what that. I assume you have local hub/router or wifi provider LOCAL to your PC? All of my machines are connected of DHCP LOCALLY and dnsmasq runs locally. I used to do this as you want on a Windows setup. Your running XAmpp which was my original Apache server. So each virtual host needed a hosts entry.

Can you please give me brief overview of your LOCAL Xamp setup: router setup... Or are you stricly one machine localhosting???

Searching for dnsmasq Windows equivalents and so far nothing. Are you running in a VM?

Update Just saw this. I loved Windows 7!

http://jqnotes.blogspot.com/2012/08/configure-windows-7-to-support-dnsmasq.html

Unsure of if it works, but sound if there is hidden dnsmasq like services inside Windows networking code.

Laragon looks interesting per other post. I personally opt for more direct control of things, but if its local to your network in may solve your immediate issues.

Viernes's avatar

@jimmck Largaon its good i think but it's still good even if i will host my application in my company internal network we have about 150 PC

Thyrosis's avatar

@Viernes Laragon is meant for local development, just as packages like Xampp and Wamp are. At least, that's what I'm reading from your posts so far: you have a Windows PC on which you are developing your application and want that to be accessible from your company's PCs?

If you are hosting an application for your company to use internally on 150 PCs, you should really set up a dedicated server. Something simple like Ubuntu or CentOS, make it available for your local company's network only and host the application on there.

Viernes's avatar

@Thyrosis thanx man but i have a few questions if my server set on CentOS can the other PC's work on windows system normally the other question my company branch working under Internal Domain and it related to the main branch but i got Admin privileges to control my branch PC as i said 150 PC each 20 connected in a switch and the entire branch of 150 PC connected through Wimax so i just have the right to Remote Connect any PC in just my branch so if i asked my Domain Controller to provide me with a server i could host an application by Laragon or Xampp in the server and it will work i guess without any conflict with our Domain Right ?!

Thyrosis's avatar

@Viernes sorry for the late reply, unfortunately I can't open the notifications thing in FireFox so didn't catch your reply and tag.

The answer is: Yes to all.

If you have a server in your network running a LAMP stack, it will get an IP address from the switch, router or whatever it is using to connect to the network. Make this IP static, so it will never change.

Then, just have your resolving for all PCs connect to that server for a given hostname. For instance for a single PC, the local host file would have this line:

intranet.local 127.0.1.57

Of course, assuming 127.0.1.57 is the static IP you've given it. And of course, you wouldn't set this individually for each PC, I'm sure there's a way to do this for all PCs simultaneously and centrally.

You could even use your company's own domain name to point everyone to it, by setting an A record to that IP for a subdomain.

intranet.yourcompany.com A 127.0.1.57

On the CentOS server you don't use Laragon or Xampp, you just install a LAMP stack. Ubuntu has a ready made package installer for that, so I'm guessing CentOS has too. If not, DigitalOcean has a wide range of very decent tutorials, like this one: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-7

As long as the server is connected to the network properly and accessible for all 150 PCs through the given IP, the whole company can use your application.

1 like
NOMGUY's avatar
<VirtualHost *:80>
    ServerAdmin [email protected]
    ##DocumentRoot "C:/xampp/htdocs/test/public"
    ServerName app.test
    ##ErrorLog "logs/dummy-host2.example.com-error.log"
    ##CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>

Why are you doing to http://me.test/dashboard/ you should go to http://app.test/dashboard/ as you have set the host to app.test and make sure you edit the hosts file running as administrator, or else it won't save any changes.

Viernes's avatar

@Thyrosis Thanks man i will give it a try (Y)

@NOMGUY i tried every solution and didn't work then i moved to Laragon and it works great

NOMGUY's avatar

@Viernes For creating a vhosts, Go to xampp/apache/conf/extra and open httpd-vhosts.conf and add these two things at the bottom:

<VirtualHost *:80>
    Document Root "C:/xampp/htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>
    Document Root "C:/xampp/htdocs/lsapp/public"
    ServerName app.test
</VirtualHost>

Save it. After that, open a Notepad as an Administrator. Click on File and select open. Then go to, C:/windows/System32/drivers/etc there you won't find any file, but hang on! From your dialog box select All files from the drop-down button near the Open button. Then you will see some files. Select hosts file and at the bottom add these two:

127.0.0.1 localhost
127.0.0.1 app.test
1 like
MaverickChan's avatar

you need to enable the vhosts mods first in httpd.conf file.

remove the # before Inlclue .../httpd- vhosts.conf

inside this httpd-vhosts.conf file , do as @NOMGUY said.

1 like

Please or to participate in this conversation.