mod_rewrite条件没有解雇?

时间:2011-04-05 20:41:23

标签: regex apache mod-rewrite cache-control clean-urls

在重定向用户之前,我想检查重定向到文件是否确实存在。现在,当我添加当前已注释掉的位时,以下代码正常工作,它完全跳过了重写规则。

<IfModule mod_rewrite.c>   
  RewriteEngine on    
  RewriteBase /   
  # RewriteCond cache/$1.html -f      
  RewriteRule ^([^/]+)/?([^/]*) cache/$1.html [L]    
<IfModule>     

我已经在这三天挣扎了,任何帮助都会非常感谢!!!

2 个答案:

答案 0 :(得分:0)

# RewriteCond cache/$1.html -f $1中没有引用任何内容,因此它会跳过您的RewriteRule。

尝试

RewriteCond %{DOCUMENT_ROOT}/cache/%{REQUEST_URI}.html -s

RewriteCond Documentation

答案 1 :(得分:-1)

我的第一印象是检查缓存/ $ 1.html是否存在以及您是否意外地从myserver.com/index.html重定向 - &gt;到 - &gt; myserver.com/cache/index.html.html

相关问题