【备忘】IIS目录结尾自动加划线

IIS6好麻烦啊。。--香港Win2012全能主机请戳这里--

理论上只要在你的规则中添加粗体的部分就可以的。注:ISAPI Rewrite 3.X规则未实测。

关于重写/重定向的其他注意事项,比如不带www的域名重写向、1.8 Z-Blog升级后的RSS地址变更……请参考之前的相关文章:

http://www.wdssmq.com/tag/301

↑↑↑ 也算是个演示地址吧。

IIS6+ISAPI Rewrite 2.X

[ISAPI_Rewrite]

RewriteRule /(?!zb_)([^\.]+[^/]) /$1/ [RP,L]
RewriteRule /default_([0-9]+)\.html /catalog\.asp\?page=$1
RewriteRule /category/(?!zb_)(.*)_([0-9]+)/ /catalog\.asp\?cate=$1&page=$2
RewriteRule /category/(?!zb_)(.*)/ /catalog\.asp\?cate=$1
RewriteRule /author-([0-9]+)_([0-9]+).html /catalog\.asp\?auth=$1&page=$2
RewriteRule /author-([0-9]+).html /catalog\.asp\?auth=$1
RewriteRule /tags-([0-9]+)_([0-9]+).html /catalog\.asp\?tags=$1&page=$2
RewriteRule /tags-([0-9]+).html /catalog\.asp\?tags=$1
RewriteRule /post/([0-9\-]+)_([0-9]+)/ /catalog\.asp\?date=$1&page=$2
RewriteRule /post/([0-9\-]+)/ /catalog\.asp\?date=$1
RewriteRule /post/(?!zb_)(.*)/ /view\.asp\?id=$1
RewriteRule /(?!zb_)(.*)/ /view\.asp\?id=$1

IIS6+ISAPI Rewrite 3.X

#ISAPI Rewrite 3
RewriteBase /
RewriteRule ^(?!zb_)([^\.]+[^/])$ /$1/ [NU,R=301]
RewriteRule ^default_([0-9]+)\.html$ /catalog.asp\?page=$1
RewriteRule ^category/(?!zb_)(.*)_([0-9]+)/$ /catalog.asp\?cate=$1&page=$2 [NU]
RewriteRule ^category/(?!zb_)(.*)/$ /catalog.asp\?cate=$1 [NU]
RewriteRule ^author-([0-9]+)_([0-9]+).html$ /catalog.asp\?auth=$1&page=$2 [NU]
RewriteRule ^author-([0-9]+).html$ /catalog.asp\?auth=$1 [NU]
RewriteRule ^tags-([0-9]+)_([0-9]+).html$ /catalog.asp\?tags=$1&page=$2 [NU]
RewriteRule ^tags-([0-9]+).html$ /catalog.asp\?tags=$1 [NU]
RewriteRule ^post/([0-9\-]+)_([0-9]+)/$ /catalog.asp\?date=$1&page=$2 [NU]
RewriteRule ^post/([0-9\-]+)/$ /catalog.asp\?date=$1 [NU]
RewriteRule ^post/(?!zb_)(.*)/$ /view.asp\?id=$1 [NU]
RewriteRule ^(?!zb_)(.*)/$ /view.asp\?id=$1 [NU]

IIS7、7.5、8+Url Rewrite

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
  <rewrite>
   <rules>
     <rule name="//" stopProcessing="true">
      <match url="^(?!zb_)[^\.]+[^/]$"/>
      <action type="Redirect" redirectType="Permanent" url="{R:0}/"/>
     </rule>

     <rule name="Imported Rule Default+Page" stopProcessing="true">
      <match url="^default_([0-9]+)\.html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?page={R:1}" />
     </rule>
     <rule name="Imported Rule Category+Page" stopProcessing="true">
      <match url="^category-([0-9]+)_([0-9]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?cate={R:1}&amp;page={R:2}" />
     </rule>
     <rule name="Imported Rule Category" stopProcessing="true">
      <match url="^category-([0-9]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?cate={R:1}" />
     </rule>
     <rule name="Imported Rule Author+Page" stopProcessing="true">
      <match url="^author-([0-9]+)_([0-9]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?auth={R:1}&amp;page={R:2}" />
     </rule>
     <rule name="Imported Rule Author" stopProcessing="true">
      <match url="^author-([0-9]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?auth={R:1}" />
     </rule>
     <rule name="Imported Rule Tags+Page" stopProcessing="true">
      <match url="^tags-([0-9]+)_([0-9]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?tags={R:1}&amp;page={R:2}" />
     </rule>
     <rule name="Imported Rule Tags" stopProcessing="true">
      <match url="^tags-([0-9]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?tags={R:1}" />
     </rule>
     <rule name="Imported Rule Date+Page" stopProcessing="true">
      <match url="^date-([0-9\-]+)_([0-9]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?date={R:1}&amp;page={R:2}" />
     </rule>
     <rule name="Imported Rule Date" stopProcessing="true">
      <match url="^date-([0-9\-]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?date={R:1}" />
     </rule>
     <rule name="Imported Rule Article" stopProcessing="true">
      <match url="^post/(?!zb_)(.*).html$" ignoreCase="false" />
      <action type="Rewrite" url="view.asp?id={R:1}" />
     </rule>
     <rule name="Imported Rule Page" stopProcessing="true">
      <match url="^(?!zb_)(.*).html$" ignoreCase="false" />
      <action type="Rewrite" url="view.asp?id={R:1}" />
     </rule>
   </rules>
  </rewrite>
 </system.webServer>
</configuration>

原文链接:http://www.wdssmq.com/post/20141208340.html

分享本文:新浪微博腾讯微博

神来一句:

  • [贱人就是矫情]
  • [人艰不拆]
  • [朕知道了]
  • [不明觉厉]
  • [这真是极好的]
  • [也真是醉了]
  • [点个赞]
  • [你那么萌你家人造吗?]
  • [涨姿势!]
赞助一下
分享