简体   繁体   中英

XAMPP Access Forbidden

I have just downloaded the latest version of XAMPP with PHP version 7.2.4. I have made a very simple PHP validation for a HTML form and when I press submit it comes up with the following:

Access forbidden! You don't have permission to access the requested object. It is either read-protected or not readable by the server.

If you think this is a server error, please contact the webmaster.

Error 403 localhost Apache/2.4.33 (Win32) OpenSSL/1.1.0g PHP/7.2.4

I'd don't know what the problem is as I have tried changing Require none to Require all granted .

Please Help!

I have experienced this problem and found out that localhost link is not configured in httpd_vhosts.conf. So I added this line at the bottom part of httpd_vhosts.conf

<VirtualHost *:80>
    DocumentRoot "E:/xampp/htdocs"
    ServerName localhost
</VirtualHost>

Well, probably this must be happening because the localhost link is not configured in your xamp vhost, try to look for the vhosts configuration file and add the same one there. Just add this block of code making the appropriate path changes until your repository so that you can access the localhost:

 # Virtual Hosts # <VirtualHost *:80> ServerName localhost ServerAlias localhost DocumentRoot "${INSTALL_DIR}/www" <Directory "${INSTALL_DIR}/www/"> Options +Indexes +Includes +FollowSymLinks +MultiViews AllowOverride All Require local </Directory> </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@hcode.com.br DocumentRoot "C:\\ecommerce" ServerName www.hcodecommerce.com.br ErrorLog "logs/dummy-host2.example.com-error.log" CustomLog "logs/dummy-host2.example.com-access.log" common <Directory "C:\\ecommerce"> Require all granted RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [QSA,L] </Directory> </VirtualHost>

By default in httpd.conf your entire system directory "/" is secured and not allowed access

in httpd.conf:

# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other 
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all denied
</Directory>

Add the below additional under the above

<Directory /home>
   Options +Indexes +Includes +FollowSymLinks +MultiViews
   AllowOverride All
   Require local
</Directory>

Change /home to your hosted installation public directory - eg /projects or /devsite.local etc...

For more info on Apache see here: https://httpd.apache.org/docs/current/mod/core.html#directory

The 'Options' are typical .htaccess directives - change as needed

The 'AllowOverride All' gives access to the /home folder and everything under it

The 'Require local' makes sure only localhost / 127.0.0.1 has access to folder and files under /home

Hope this helps :D

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