關於偽靜態一個有關問題,突然忘記一段代碼了

來源:互聯網
上載者:User
關於偽靜態一個問題,突然忘記一段代碼了
我要達到這麼一種效果:當index.html存在的時候,就訪問存在的index.html檔案,不存在的時候,就通過偽靜態去動態訪問,配置如下:



RewriteEngine ON

RewriteCond %{HTTP_HOST} ^(.*)www.aaa.com$ [OR]
RewriteCond %{HTTP_HOST} ^([^www]*).aaa.com$
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ http://www.aaa.com.$1 [R,QSA,L]

RewriteRule ^/([a-zA-Z]+)\.html$/run.php?controller=$1&action=$1&default=1 [L]

ServerAdmin admin@yahoo.com.cn
DocumentRoot "E:/www/home"
ServerName www.aaa.com
ErrorLog "D:/AppServ/log/index_error.log"
CustomLog "D:/AppServ/log/index_access.log" common
ErrorDocument 404 http://www.aaa.com/error_404.html
ErrorDocument 403 http://www.aaa.com/error_403.html


Options Indexes FollowSymLinks
DirectoryIndex index.html
AllowOverride None
Order deny,allow
Allow from all





但是上面的配置有問題,當index.html存在的時候,系統也通過偽靜態去訪問了,求助。
我確定我要做的效果是可以達到的,以前這樣做過,後來配置弄丟了,怎麼想也想不起來哪裡寫錯了。
求助,謝謝。


------解決方案--------------------
#如果目錄存在就直接存取目錄不進行RewriteRule
RewriteCond %{REQUEST_FILENAME} !-d

#如果檔案存在,就直接存取檔案,不進行下面的RewriteRule.(不是檔案或檔案不存在就執行重寫)
RewriteCond %{REQUEST_FILENAME} !-f

------解決方案--------------------
學習了……
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.