繁体   English   中英

禁止 XAMPP 访问

[英]XAMPP Access Forbidden

我刚刚下载了最新版本的 XAMPP,PHP 版本为 7.2.4。 我为 HTML 表单做了一个非常简单的 PHP 验证,当我按下提交时,它会出现以下内容:

禁止访问! 您无权访问所请求的对象。 它要么受读保护,要么无法被服务器读取。

如果您认为这是服务器错误,请联系网站管理员。

错误 403 本地主机 Apache/2.4.33 (Win32) OpenSSL/1.1.0g PHP/7.2.4

我不知道问题是什么,因为我已经尝试将Require none更改为Require all granted

请帮忙!

我遇到过这个问题,发现httpd_vhosts.conf中没有配置localhost链接。 所以我在 httpd_vhosts.conf 的底部添加了这一行

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

好吧,这可能是因为 localhost 链接未在您的 xamp vhost 中配置,请尝试查找 vhosts 配置文件并在那里添加相同的配置文件。 只需添加此代码块,在您的存储库之前更改适当的路径,以便您可以访问本地主机:

 # 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>

默认情况下,在 httpd.conf 中,您的整个系统目录“/”是安全的,不允许访问

在 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>

在上面的下面添加下面的附加项

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

将 /home 更改为您的托管安装公共目录 - 例如 /projects 或 /devsite.local 等...

有关 Apache 的更多信息,请参见此处: https : //httpd.apache.org/docs/current/mod/core.html#directory

“选项”是典型的 .htaccess 指令 - 根据需要更改

“AllowOverride All”允许访问 /home 文件夹及其下的所有内容

'Require local' 确保只有 localhost / 127.0.0.1 可以访问 /home 下的文件夹和文件

希望这会有所帮助:D

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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