Domanda

I'm trying to create a virtual host in apache so I can access a local site via localhost but using a different port than the default :80, what I want is that http://localhost:8080 loads my site directly in the folder I specify, I have the following set up in my httpd-vhosts.conf file which is working partially:

Listen 8080
NameVirtualHost *:8080

<VirtualHost 127.0.0.1:8080>
    DocumentRoot "c:\wamp\www\trend\public"
    ServerName local.trend
</VirtualHost>

If I go to http://localhost:8080 the page loads fine but if I go to http://local.trend then it just shows me the same as if I go to http://localhost is there any way to change it so it works with the server name as well?

Should I edit my hosts file? I currently have:

127.0.0.1 localhost local.trend

È stato utile?

Soluzione

Your hosts file is correct as it stands now.

If you want http://local.trend to go to the same target as http://local.trend:8080 (which is what you have configured above), you'll need to add a separate VirtualHost for that host on port 80:

<VirtualHost 127.0.0.1:80>
    DocumentRoot "c:\wamp\www\trend\public"
    ServerName local.trend
</VirtualHost>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top