22
.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模式的。 – BoltClock