简体   繁体   中英

WAMP Virtual host not working properly

I've been configuring my virtual hosting, with the following code:

<Virtualhost *:80>

    ServerName devproject.local
    ServerAlias devproject.local

    DocumentRoot "C:/wamp/www/devproject"
    <Directory "C:/wamp/www/devproject">
        Allow from all
    </Directory>

</Virtualhost>

And wanted the result, that whenever I connect to 'devproject.local/', the project 'devproject' (which is located in my root directory 'C:/wamp/www/devproject) actually loads in.

The effect i'm currently having, is that the whole root ('/www/' directory) is loading in. So the URL has to be 'devproject.local/devproject' instead of 'devproject.local' for loading in the project.

Could anyone tell me what i'm doing wrong?

As discussed in comments:

Apache typically has the main config in the conf/httpd.conf file.

Typically this contains a line such as this:

#Include conf/extra/httpd-vhosts.conf

Due to that # at the beginning this extra config file is commented out and not included. Therefore any config in this vhosts file is not used.

You probably have the main DocumentRoot httpd.conf set to C:/wamp/www/ hence why Apache will return return the website at http://devproject.local/devproject despite not loading this vhost file.

Btw if you only have on host in the Apache instance then normally don't need vhosts file (hence why it's commented out by default). It's more useful when you have multiple hosts on the same site (under different DNS names or ports).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM