ISAPI_Rewrite3中httpd.conf和.htaccess配置规则的细微区别

今天在使用ISAPI_Rewrite3为各个站点配置伪静态时,发现在全局httpd.conf中配置的伪静态规则可使用,而把配置规则拷贝到网站根目录的.htaccess文件,并清空全局httpd.conf后却后现伪静态无法使用了。

后来看到了:

If rules are working in httpd.conf file but not in other sections or .htaccess files, make sure to include RewriteEngine on directive in every section and .htaccess file. Also remember that rewriting base inside .htaccess files by default is different from httpd.conf. ISAPI_Rewrite automatically strips the local directory prefix from the path when in .htaccess or <Directory> section and applies rules only to the remainder. So if your rules start with a ‘/’ character, this should be removed in .htaccess file in the root folder of web site.

原来httpd.conf和.htaccess的规则还是不太一样

如:

httpd.conf中的配置规则是:RewriteRule /(\w+)/list(\d+).html  /Article/ArticleList.aspx\?ArticleType=$1&Page=$2

.htaccess中的配置规则需要修改为:RewriteRule (\w+)/list(\d+).html  /Article/ArticleList.aspx\?ArticleType=$1&Page=$2

 

So if your rules start with a ‘/’ character, this should be removed in .htaccess file in the root folder of web site.

你可能感兴趣的:(rewrite)