rewriteengine on
rewriterule ^/a/b$ ^/c$
不工作,但
rewriteengine on
rewritebase /
rewriterule ^a/b$ ^c$
的作品。
这也许不一定就是规则的工作这么多,因为领先的斜线的RewriteBase。此外,第二个参数重写规则是不是正规的前pression。相反,尝试:
It's probably not the RewriteBase that makes the rule work so much as the leading slash. Also, the second argument to RewriteRule isn't a regular expression. Instead, try:
RewriteRule ^/?a/b$ c
当应用从一个的.htaccess重写规则,领先的斜线将从URL,这将导致如果包括它的模式失败剥离。通过启动一个模式以^ /?,它会在主配置文件,并在每个目录的配置文件。
When applying a RewriteRule from .htaccess, the leading slash will be stripped from the URL, which will cause the pattern to fail if you include it. By starting a pattern with "^/?", it will work in the main configuration files and in per-directory config files.
详细阅读详细的mod_rewrite文档和的RewriteBase的意义
Read over the detailed mod_rewrite documentation for the details of how the rewrite engine works and the significance of RewriteBase.
编辑: 正如在 mod_rewrite的技术详细信息和的