[英]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.