【发布时间】:2011-10-03 01:07:41
【问题描述】:
.htaccess 中的%1 和$1 有什么区别?
例如,
# to remove www
RewriteCond %{HTTP_HOST} ^(\w+)\.mydomain\.com [NC]
RewriteRule .* http://mydomain.com/%1 [R=301,L]
# versus
# RewriteRule .* http://mydomain.com/$1 [R=301,L]
我一直在使用 Dave Child's .htaccess cheat sheet 和 Jackol's .htaccess cheat sheet 以及 Apache mod_rewrite docs,但额外的帮助会很棒。
【问题讨论】:
-
mod_rewrite文档说%N反向引用用于 RewriteCond 模式,而$N反向引用用于 RewriteRule 模式。
标签: apache .htaccess mod-rewrite