XAMPP 禁止访问
XAMPP Access Forbidden
我刚刚下载了 XAMPP 的最新版本 PHP 版本 7.2.4。我为 HTML 表单做了一个非常简单的 PHP 验证,当我按下提交时,它会出现以下内容:
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
我不知道问题出在哪里,因为我已经尝试将 Require none
更改为 Require all granted
。
请帮忙!
好吧,这可能一定会发生,因为本地主机 link 未在您的 xamp 虚拟主机中配置,请尝试查找虚拟主机配置文件并在其中添加相同的配置文件。只需添加此代码块进行适当的路径更改,直到您的存储库,以便您可以访问本地主机:
# 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>
我遇到过这个问题,发现本地主机link没有配置在
httpd_vhosts.conf。
所以我在 httpd_vhosts.conf
的底部添加了这一行
<VirtualHost *:80>
DocumentRoot "E:/xampp/htdocs"
ServerName localhost
</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 更改为您的托管安装 public 目录 - 例如/projects 或 /devsite.local 等...
有关 Apache 的更多信息,请参阅此处:https://httpd.apache.org/docs/current/mod/core.html#directory
'Options' 是典型的 .htaccess 指令 - 根据需要进行更改
'AllowOverride All' 允许访问 /home 文件夹及其下的所有内容
'Require local' 确保只有 localhost / 127.0.0.1 可以访问 /home
下的文件夹和文件
希望对您有所帮助 :D
我刚刚下载了 XAMPP 的最新版本 PHP 版本 7.2.4。我为 HTML 表单做了一个非常简单的 PHP 验证,当我按下提交时,它会出现以下内容:
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
我不知道问题出在哪里,因为我已经尝试将 Require none
更改为 Require all granted
。
请帮忙!
好吧,这可能一定会发生,因为本地主机 link 未在您的 xamp 虚拟主机中配置,请尝试查找虚拟主机配置文件并在其中添加相同的配置文件。只需添加此代码块进行适当的路径更改,直到您的存储库,以便您可以访问本地主机:
# 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>
我遇到过这个问题,发现本地主机link没有配置在 httpd_vhosts.conf。 所以我在 httpd_vhosts.conf
的底部添加了这一行<VirtualHost *:80>
DocumentRoot "E:/xampp/htdocs"
ServerName localhost
</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 更改为您的托管安装 public 目录 - 例如/projects 或 /devsite.local 等...
有关 Apache 的更多信息,请参阅此处:https://httpd.apache.org/docs/current/mod/core.html#directory
'Options' 是典型的 .htaccess 指令 - 根据需要进行更改
'AllowOverride All' 允许访问 /home 文件夹及其下的所有内容
'Require local' 确保只有 localhost / 127.0.0.1 可以访问 /home
下的文件夹和文件希望对您有所帮助 :D