RewriteRule checking file in rewriten file path exists

后端 未结 2 1344
说谎
说谎 2020-12-03 02:18

How can you use ModRewrite to check if a cache file exists, and if it does, rewrite to the cache file and otherwise rewrite to a dynamic file.

For example I have th

2条回答
  •  南笙
    南笙 (楼主)
    2020-12-03 02:27

    Another approach would be to first look if there is a chached representation available:

    RewriteCond %{DOCUMENT_ROOT}/cache/$0 -f
    RewriteRule ^pages/[^/\.]+$ cache/$0.html [L,QSA]
    
    RewriteRule ^pages/([^/\.]+)$ pages.php?p=$1 [L,QSA]
    

提交回复
热议问题