Tuesday, January 4, 2022

[SOLVED] Apache virtual host on different ports doesn't work

Issue

I'm trying to serve different folders on my localhost. I'm using Windows OS.

I want to serve E:/Programming/Projects on localhost:8080, and E:/htdocs on localhost:80

My httpd-vhosts.conf file is like that:

Listen 8080
<VirtualHost *:8080>
    ServerName localhost
    DocumentRoot "E:/Programming/Projects"
    <Directory "E:/Programming/Projects">
        AllowOverride All
    </Directory>

</VirtualHost>

When I attempt to navigate localhost:80, this port works well. But localhost:8080 gives this error:

403 - Forbidden
You don't have permission to access this resource.

I've reset my server, but it doesn't work.


Solution

The correct answer is:

Listen 8080

<VirtualHost *:8080>
    ServerName localhost:8080
    DocumentRoot "E:/Programming/Projects/"
    <Directory "E:/Programming/Projects/">
        Options +Indexes +FollowSymLinks +MultiViews
        require all granted
    </Directory>
</VirtualHost>


Answered By - sundowatch