3

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

禁止访问!您无权访问请求的对象。它要么是读保护的,要么是服务器不可读的。

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

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

我不知道问题是什么,因为我尝试更改Require noneRequire all granted.

请帮忙!

4

3 回答 3

5

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

<VirtualHost *:80>
    DocumentRoot "E:/xampp/htdocs"
    ServerName localhost
</VirtualHost>
于 2018-06-14T12:51:25.703 回答
1

好吧,这可能一定是因为 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>

于 2018-04-26T18:21:06.133 回答
0

默认情况下,在 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 文件夹及其下的所有内容

“需要本地”确保只有 localhost / 127.0.0.1 可以访问 /home 下的文件夹和文件

希望这会有所帮助:D

于 2020-02-01T01:58:25.550 回答