2012-07-04 78 views
-1

我嘗試了許多組合,但都沒有工作。我試圖寫重寫規則,其中:重寫首先緩存的內容

  1. 承擔http://example.com/project/big_bunny
  2. URL當用戶訪問網站的rewrite先嚐試讀取文件/cache/project/big_bunny.html但前提是沒有任何get或post數據
  3. 如果沒有緩存改寫處理標準路由器規則:1的index.php _rt = $ [L,QSA]

有什麼建議?

回答

0

試試這個:

# Check the cache, and rewrite if file exists 
RewriteCond %{THE_REQUEST} !^POST [NC] 
RewriteCond %{QUERY_STRING} ^$ 
RewriteCond %{DOCUMENT_ROOT}/cache%{REQUEST_URI}.html -f 
RewriteRule^/cache%{REQUEST_URI}.html [L] 

# If URI doesn't start with /cache/, it wasn't cached so rewrite to index.php 
RewriteCond %{REQUEST_URI} !^/cache/ 
RewriteRule ^(.*)$ index.php?_rt=$1 [L,QSA] 
0

試試這個:

# Check if using POST method 
RewriteCond %{THE_REQUEST} !^POST 
# Check if already rewrote to cache 
RewriteCond %{REQUEST_URI} !^/cache 
# Check if cache exists 
RewriteCond /cache%{REQUEST_URI}.html -f 
# Check if contains any GET query string 
RewriteCond %{QUERY_STRING} !.+ 
# Do the rewrite 
RewriteRule ^/(.*) /cache/$1.html [L] 

# Check if already rewrote to cache 
RewriteCond %{REQUEST_URI} !^/cache 
RewriteRule ^/(.*) index.php?_rt=$1 [L,QSA]