apache拒絕訪問文件
A. 403拒絕訪問解決辦法有哪些
解決403 forbidden錯誤的方法:
1、重建dns緩存
對於一些常規的403 forbidden錯誤,馬海祥建議大家首先要嘗試的就是重建dns緩存,在運行中輸入cmd,然後輸入ipconfig /flushdns即可。如果不行的話,就需要在hosts文件里把主頁解析一下了。
同時,查看是否在網站虛擬目錄中添加默認文檔,一般默認文檔為:index.html;index.asp;index.php;index.jsp;default.htm;default.asp等。
2、修改文件夾安全屬性
用以下命令修改文件夾安全屬性
chcon -R -t httpd_user_content_t public_html/
所用命令解析:
ls -Z -d public_html/#顯示文件/目錄的安全語境-Z, --context Display security context so it fits on most displays. Displays only mode, user, group, security context and file name.-d, --directory list directory entries instead of contents, and do not dereference symbolic links chcon -R -t httpd_user_content_t public_html/#修改文件/目錄的安全語境-R, --recursive change files and directories recursively-t, --type set type TYPE in the target security context
3、關於apache導致的403 forbidden錯誤的解決辦法
打開apache的配置文件httpd.conf,找到這段代碼:
Options FollowSymLinks AllowOverride None Order deny,allow Deny from all
有時候由於配置了php後,這里的「Deny from all」已經拒絕了一切連接。把該行改成「allow from all」,修改後的代碼如下,問題解決。
Options FollowSymLinks AllowOverride None Order deny,allow Allow from all
之所以會出現錯誤,是因為大多數的國外主機在配置Apache的時候啟用了mod_security,也就是開啟了安全檢查,如果提交的信息中包含select , % , bin等關鍵字,Apache就會禁止,並給出403,404,500等錯誤。