[windows] Apache gives me 403 Access Forbidden when DocumentRoot points to two different drives

I am getting an 403 access forbidden when attempting to open a page under a vhost where the document root is sitting on a different drive than where apache is sitting. I installed using the apachefriends release. This is my httpd-vhosts.conf file:


NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1> ServerName foo.localhost DocumentRoot "C:/xampp/htdocs/foo/public" </VirtualHost>

<VirtualHost 127.0.0.1> ServerName bar.localhost DocumentRoot "F:/bar/public" </VirtualHost>

When opening bar.localhost in my browser, Apache is giving me 403 Access Forbidden. I tried setting lots of different access rights, even full rights to everyone, but nothing I tried helped.

Edit: Thanks! For future reference, add 'Options indexes' within to show directory indexes.

This question is related to windows apache virtualhost http-status-code-403

The answer is


You did not need

Options Indexes FollowSymLinks MultiViews Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted

the only thing what you need is...

Require all granted

...inside the directory section.

See Apache 2.4 upgrading side:

http://httpd.apache.org/docs/2.4/upgrading.html


Somewhere, you need to tell Apache that people are allowed to see contents of this directory.

<Directory "F:/bar/public">
    Order Allow,Deny
    Allow from All
    # Any other directory-specific stuff
</Directory>

More info


For Apache 2.4.2: I was getting 403: Forbidden continuously when I was trying to access WAMP on my Windows 7 desktop from my iPhone on WiFi. On one blog, I found the solution - add Require all granted after Allow all in the <Directory> section. So this is how my <Directory> section looks like inside <VirtualHost>

<Directory "C:/wamp/www">
    Options Indexes FollowSymLinks MultiViews Includes ExecCGI
    AllowOverride All
    Order Allow,Deny
    Allow from all
    Require all granted
</Directory>

I have fixed it with removing below code from

C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf file

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error.log"
    CustomLog "logs/dummy-host.example.com-access.log" common
 </VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>

And added

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "c:/wamp/www"
    ServerName localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
</VirtualHost>

And it has worked like charm


Solved 403: Forbidden when visiting localhost. Using ports 80,443,3308 (the later to handle conflict with MySQL Server installation) Windows 10, XAMPP 7.4.1, Apache 2.4.x My web files are in a separate folder.

httpd.conf - look for these lines and set it up where you have your files, mine is web folder.

DocumentRoot "C:/web"
<Directory "C:/web">

Changed these 2 lines.

<VirtualHost *:80>
 ServerAdmin [email protected]
 DocumentRoot "C:/web/project1"
 ServerName project1.localhost
 <Directory "C:/web/project1">
  Order allow,deny
  allow from all
 </Directory>
</VirtualHost>

to this

<VirtualHost *:80>
 ServerAdmin [email protected]
 DocumentRoot "C:/web/project1"
 ServerName project1.localhost
 <Directory "C:/web/project1">
  Require all granted
 </Directory>
</VirtualHost>

Add your details in your hosts file C:\Windows\System32\drivers\etc\hosts file

127.0.0.1 localhost
127.0.0.1 project1.localhost

Stop start XAMPP, and click Apache admin (or localhost) and the wonderful XAMPP dashboard now displays! And visit your project at project1.localhost


Questions with windows tag:

"Permission Denied" trying to run Python on Windows 10 A fatal error occurred while creating a TLS client credential. The internal error state is 10013 How to install OpenJDK 11 on Windows? I can't install pyaudio on Windows? How to solve "error: Microsoft Visual C++ 14.0 is required."? git clone: Authentication failed for <URL> How to avoid the "Windows Defender SmartScreen prevented an unrecognized app from starting warning" XCOPY: Overwrite all without prompt in BATCH Laravel 5 show ErrorException file_put_contents failed to open stream: No such file or directory how to open Jupyter notebook in chrome on windows Tensorflow import error: No module named 'tensorflow' git clone error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054 bash: npm: command not found? Anaconda Installed but Cannot Launch Navigator AttributeError: module 'cv2.cv2' has no attribute 'createLBPHFaceRecognizer' How to install pandas from pip on windows cmd? 'ls' in CMD on Windows is not recognized Copy Files from Windows to the Ubuntu Subsystem Tensorflow r1.0 : could not a find a version that satisfies the requirement tensorflow Kill tomcat service running on any port, Windows python pip on Windows - command 'cl.exe' failed How to install pip3 on Windows? Mount current directory as a volume in Docker on Windows 10 Specifying Font and Size in HTML table Why Local Users and Groups is missing in Computer Management on Windows 10 Home? Command to run a .bat file How do I force Robocopy to overwrite files? Windows- Pyinstaller Error "failed to execute script " When App Clicked How to completely uninstall Android Studio from windows(v10)? Docker for Windows error: "Hardware assisted virtualization and data execution protection must be enabled in the BIOS" How do I kill the process currently using a port on localhost in Windows? Error : getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443 How to add a custom CA Root certificate to the CA Store used by pip in Windows? How to reset the use/password of jenkins on windows? npm ERR! Error: EPERM: operation not permitted, rename CMD (command prompt) can't go to the desktop Xampp-mysql - "Table doesn't exist in engine" #1932 Change drive in git bash for windows "OverflowError: Python int too large to convert to C long" on windows but not mac Visual studio code terminal, how to run a command with administrator rights? ImportError: cannot import name NUMPY_MKL Pip - Fatal error in launcher: Unable to create process using '"' Installing tensorflow with anaconda in windows Where does Anaconda Python install on Windows? PermissionError: [Errno 13] Permission denied How to restart a windows service using Task Scheduler How to install xgboost in Anaconda Python (Windows platform)? NPM stuck giving the same error EISDIR: Illegal operation on a directory, read at error (native) Can't access 127.0.0.1 anaconda - path environment variable in windows Global npm install location on windows?

Questions with apache tag:

Enable PHP Apache2 Switch php versions on commandline ubuntu 16.04 Laravel: PDOException: could not find driver How to deploy a React App on Apache web server Apache POI error loading XSSFWorkbook class How to enable directory listing in apache web server Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details How to enable php7 module in apache? java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing while starting Apache server on my computer WAMP won't turn green. And the VCRUNTIME140.dll error MySQL error - #1932 - Table 'phpmyadmin.pma user config' doesn't exist in engine SSL error SSL3_GET_SERVER_CERTIFICATE:certificate verify failed resource error in android studio after update: No Resource Found XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page Getting a 500 Internal Server Error on Laravel 5+ Ubuntu 14.04 installing apache: no VCRUNTIME140.dll Could not load the Tomcat server configuration How to add Apache HTTP API (legacy) as compile-time dependency to build.grade for Android M? Apache Server (xampp) doesn't run on Windows 10 (Port 80) How to set up file permissions for Laravel? Chrome net::ERR_INCOMPLETE_CHUNKED_ENCODING error How to allow Cross domain request in apache2 Getting Error:JRE_HOME variable is not defined correctly when trying to run startup.bat of Apache-Tomcat Netbeans 8.0.2 The module has not been deployed Only variable references should be returned by reference - Codeigniter laravel the requested url was not found on this server httpd-xampp.conf: How to allow access to an external IP besides localhost? WebSockets and Apache proxy : how to configure mod_proxy_wstunnel? How to force reloading php.ini file? XAMPP: Couldn't start Apache (Windows 10) how to create virtual host on XAMPP phpmyadmin "Not Found" after install on Apache, Ubuntu XAMPP installation on Win 8.1 with UAC Warning Httpd returning 503 Service Unavailable with mod_proxy for Tomcat 8 how to configure apache server to talk to HTTPS backend server? How to fix PHP Warning: PHP Startup: Unable to load dynamic library 'ext\\php_curl.dll'? error running apache after xampp install How to enable local network users to access my WAMP sites? Apache Proxy: No protocol handler was valid OSError - Errno 13 Permission denied Project Links do not work on Wamp Server WAMP Cannot access on local network 403 Forbidden Apache 2.4 - Request exceeded the limit of 10 internal redirects due to probable configuration error How to enable CORS in apache tomcat Apache won't start in wamp Execute PHP script in cron job "End of script output before headers" error in Apache Starting of Tomcat failed from Netbeans Tomcat in Intellij Idea Community Edition

Questions with virtualhost tag:

how to create virtual host on XAMPP Site does not exist error for a2ensite nginx missing sites-available directory Apache VirtualHost and localhost Apache error: _default_ virtualhost overlap on port 443 Adding VirtualHost fails: Access Forbidden Error 403 (XAMPP) (Windows 7) client denied by server configuration Apache VirtualHost 403 Forbidden How to debug an apache virtual host configuration? Apache default VirtualHost Virtualhost For Wildcard Subdomain and Static Subdomain Apache gives me 403 Access Forbidden when DocumentRoot points to two different drives error_log per Virtual Host?

Questions with http-status-code-403 tag:

Nginx 403 error: directory index of [folder] is forbidden HTTP error 403 in Python 3 Web Scraping MVC4 HTTP Error 403.14 - Forbidden Error message "Forbidden You don't have permission to access / on this server" WAMP 403 Forbidden message on Windows 7 Apache VirtualHost 403 Forbidden Nginx 403 forbidden for all files Emulate a 403 error page 403 Forbidden vs 401 Unauthorized HTTP responses Apache gives me 403 Access Forbidden when DocumentRoot points to two different drives