[轉]apache下htaccess不起做用,linux,windows詳解

可能出現下面這三種的錯誤可能性: php

第一種:啓用 rewrite 和 .htaccess 設置html

rewrite設置:找到apache的配置文件httpd.conf文件,找到:#LoadModule rewrite_module modules/mod_rewrite.so去掉前面的#號。linux

改成:LoadModule rewrite_module modules/mod_rewrite.soapache

.htaccess設置windows

windows裏面這樣設置:AccessFileName htaccess  服務器

linux裏面這樣設置:AccessFileName .htaccess。ide

linux比windows裏面文件名前面多了一個點。若是沒找到AccessFileName本身在httpd.conf文件最後面加上。svn

 

第二種:AllowOverride 的設置。spa

默認AllowOverride 爲AllowOverride none。把這個改成:AllowOverride All。若是配置了多個虛擬目錄需在每一個目錄裏面開啓,實例:htm

<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

 前兩種是配置中常見的錯誤,第三種通常少見,最後提醒你們一下,記得配置文件改好後必定要重啓服務器啊。有問題,留言,或收聽微薄。

相關文章
相關標籤/搜索