關於偽靜態一個問題,突然忘記一段代碼了
我要達到這麼一種效果:當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
------解決方案--------------------
學習了……