-1
我嘗試了許多組合,但都沒有工作。我試圖寫重寫規則,其中:重寫首先緩存的內容
- 承擔http://example.com/project/big_bunny
- URL當用戶訪問網站的rewrite先嚐試讀取文件/cache/project/big_bunny.html但前提是沒有任何get或post數據
- 如果沒有緩存改寫處理標準路由器規則:1的index.php _rt = $ [L,QSA]
有什麼建議?
我嘗試了許多組合,但都沒有工作。我試圖寫重寫規則,其中:重寫首先緩存的內容
有什麼建議?
試試這個:
# 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]
試試這個:
# 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]