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

來源:互聯網
上載者:User

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

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

 前兩種是配置中常見的錯誤,第三種一般少見,最後提醒大家一下,記得設定檔改好後一定要重啟伺服器啊。有問題,留言,或收聽微薄。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.