可能出現下面這三種的錯誤可能性:
第一種:啟用 rewrite 和 .htaccess 設定
rewrite設定:找到apache的設定檔httpd.conf檔案,找到:#LoadModule rewrite_module modules/mod_rewrite.so去掉前面的#號。
改為:LoadModule rewrite_module modules/mod_rewrite.so
.htaccess設定:
windows裡面這樣設定:AccessFileName htaccess
linux裡面這樣設定:AccessFileName .htaccess。
linux比windows裡面檔案名稱前面多了一個點。如果沒找到AccessFileName自己在httpd.conf檔案最後面加上。
第二種:AllowOverride 的設定。
預設AllowOverride 為AllowOverride none。把這個改為:AllowOverride All。如果配置了多個虛擬目錄需在每個目錄裡面開啟,執行個體:
<VirtualHost *:80>
DocumentRoot "D:SvnTracsvnSVNRepositorywwwroot"
ServerName 127.0.0.1:80
DirectoryIndex index.html index.htm index.php index.shtml
<Directory "D:SvnTracsvnSVNRepositorywwwroot">
Options Indexes FollowSymLinks
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 127.0.0.2:80>
DocumentRoot "D:/SvnTrac/svn/SVNRepository/www/"
ServerName 127.0.0.2:80
DirectoryIndex index.html index.htm index.php index.shtml
<Directory "D:/SvnTrac/svn/SVNRepository/www/">
Options Indexes FollowSymLinks
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
第三種:Options 的設定
預設設定是:Options Indexes FollowSymLinks
如果改成以下設定後,就會出錯
Options Indexes FollowSymLinks MultiViews Includes (出錯)
如果要啟用,瀏覽目錄 MultiViews
伺服器端包含 Includes (<!–#include virtual=”top.htm” –>)
為了簡單可以設定為:Options All
前兩種是配置中常見的錯誤,第三種一般少見,最後提醒大家一下,記得設定檔改好後一定要重啟伺服器啊。有問題,留言,或收聽微薄。