XAMPP访问被拒绝

3
我刚刚下载了带有PHP 7.2.4版本的XAMPP最新版本。我为一个HTML表单创建了一个非常简单的PHP验证,当我点击提交时,它显示以下内容:
访问被禁止!您没有访问所请求对象的权限。它要么是受读保护的,要么无法被服务器读取。
如果您认为这是服务器错误,请联系网站管理员。
错误403 localhost Apache/2.4.33 (Win32) OpenSSL/1.1.0g PHP/7.2.4
我不知道问题出在哪里,因为我已经尝试将“Require none”更改为“Require all granted”。
请帮忙!

试试这个,对我很有帮助 https://dev59.com/UmMm5IYBdhLWcg3wKskj#23594870 - Hamza Qureshi
3个回答

5

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

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

应用这些更改后,请在隐身模式下进行测试。 - saber tabatabaee yazdi

1

很可能是因为您的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>


我将这段代码复制到了apache\conf\httpd.conf文件中,并更改了文件目录,但现在Apache甚至无法运行,并显示以下错误信息[mpm_winnt:notice] [pid 3336:tid 584] AH00354: Child: Starting 150 worker threads. - Zac Cotterell
需要所有授权 RewriteEngine 开启 RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [QSA,L]这对我有用。谢谢 - adeel ahmad

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

'Options'是典型的.htaccess指令 - 根据需要进行更改

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

'Require local'确保只有本地主机/127.0.0.1可以访问/home文件夹和文件

希望这可以帮助到您:D


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接