我有一个创建动态生成的PHP文件静态的html文件的缓存方案。我目前使用PHP来检查缓存版本的存在,如果是这样我成为它和PHP退出。作为这个问题的(http://stackoverflow.com/questions/5612735/using-mod-rewrite-to-view-cached-version-from-usual-url),我觉得这是在浪费时间。不过,我有大约5000页,因此,我将preFER不要把他们都在同一个/缓存/目录。我反而喜欢把
I have a caching program that creates static html files of dynamically generated php files. I currently use php to check if the cached version exists, if it does I serve it up and php exits. As in this question (http://stackoverflow.com/questions/5612735/using-mod-rewrite-to-view-cached-version-from-usual-url), I feel this is a waste of time. However, I have around 5,000 pages and as such, I would prefer not to place them all in the same /cache/ directory. I would instead like to place
/a-web-url/ in /cache/a/a-web-url.html.gz
和
/this-is-another-url/ in /cache/t/this-is-another-url.html.gz
我目前正在与
I am currently working with
RewriteRule ^([A-Za-z0-9-_/.]+)/$ /cache/$1
不过这个假设都是在同一个目录。我想preFER他们被分为若干子目录。谢谢你。
However this assumes that all are in the same directory. I would prefer them to be divided into subdirectories. Thanks.
另外请注意,我的所有文件末尾.html.gz
Also note that all of my files end in .html.gz
使用规则
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/?cache/ [NC]
RewriteRule ^/?(.)(.*?)/?$ /cache/${lc:$1}/${lc:$1}${lc:$2}.html.gz [L]