2013-07-18 124 views
0

在我的網站上,幾乎每個站點都被緩存。靜態htmfile從PHP寫入文件夾:mod_rewrite:搜索子目錄中的域根

/__ turbo_realcache/

如果mydomain.com/sitex.htm被訪問者請求,阿帕奇如果找到該文件首先查找這裏:

/__turbo_realcache/sitex.htm 

如果找到該文件將它傳遞給用戶。如果該文件不存在於緩存子文件夾中,則請求將在內部重定向到index.php(生成輸出的地方)並通過php打印出來。

這很好,但它在請求域根目錄時不起作用。因此,如果用戶調用

mydomain.com 

什麼我seachring的是: 如果訪問者請求在他的瀏覽器mydomain.com那麼htaccess的應該尋找一個叫做靜態HTMLFILE

/__turbo_realcache/index.htm

如果找到了,給它的用戶(如何做到這一點?)。 如果找不到,重定向到index.php(已經在工作)。

這是我的完整的htaccess:

RewriteEngine on 

# redirect www to non www 
############################################################################# 
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] 
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 


# search for realcache static files. if found stop and be happy. 
############################################################################# 
RewriteCond   %{DOCUMENT_ROOT}/__turbo_realcache/%{REQUEST_URI} -f 
RewriteRule ^(.+) %{DOCUMENT_ROOT}/__turbo_realcache/$1 [L] 


# Don't apply to URLs that go to existing files or folders. 
# Everything else goes to index.php where I decide what is shown to the user. 
############################################################################# 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php 

回答

0

realcache靜態文件規則後添加此。

RewriteCond %{REQUEST_URI} ^/$ 
RewriteCond %{DOCUMENT_ROOT}/__turbo_realcache/index.htm -f 
RewriteRule^%{DOCUMENT_ROOT}/__turbo_realcache/index.htm [L]