2008年6月16日 星期一

訪問網站403錯誤 Forbidden解決方法


關鍵錯誤:
You don't have permission to access / on this server打開網頁,結果訪問提示:403錯誤!關閉了IE的"顯示友好的HTTP錯誤",顯示沒有權限訪問(You don't have permission to access / on this server)!

我想著大概是沒有權限去訪問該目錄,因為一般情況下,NTFS對訪問權限控制的很嚴格的!於是打開目錄,一看,訪問權限居然是everyone的完全控制!
那用戶在文件夾訪問權限上是絕對沒有問題了!
肯定是apache的配置問題了,於是上網搜索,找到如下相關信息,用於修改權限.

以下為引用的內容:

Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Satisfy all


根據配置文件提示,此設置是用於修改Apache對所有目錄的訪問權限的,如果任意修改,可能會帶來安全隱患的!
那我們來看看到底是什麼在作祟,讓我們無法訪問網頁的吧!
Deny from all 有點英文基礎的都可以看的出來,這裡是關鍵:拒絕所有!
將Deny改為Allow試試!(因為可能會存在大小寫敏感的問題,所以推薦用首字母大寫,有興趣的可以自己嘗試小寫!)一下通過了,但是這樣配置的話服務器安全性會...於是我繼續往下看配置文件!

發現了以下內容
#
# This should be changed to whatever you set DocumentRoot to.
#

以上這行注釋的意思:無論你的服務器根目錄設置為什麼,你都必須保證此處配置保持一致!
以下為引用的內容:

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
# Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
# AllowOverride None
#
# Controls who can get stuff from this server.
# Order allow,deny
Allow from all
再將以上的"默認目錄"設置為"目標目錄",(當然已經將對所有權限訪問的設置修改為拒絕了!)刷新一下頁面,OK,通過了!