apache下htaccess不起作用,linux,windows詳解


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

第一種:啟用 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

 

轉自:http://blog.csdn.net/feng2375/article/details/7359153


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM