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

吐槽/反馈/建议:我的咸鱼心  爱发电-@wdssmq

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

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

https://www.wdssmq.com/tags/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>

爱发电

本文标题:《【备忘】IIS目录结尾自动加斜线》作者:沉冰浮水
原文链接:https://www.wdssmq.com/post/20141208340.html
特别注明外均为原创,转载请注明。

分享到微信

扫描二维码

可在微信查看或分享至朋友圈。

相关文章

沉冰浮水 沉冰浮水 发布于 2014-12-12 16:21:49  
https://www.wdssmq.com
[godsay4-不明觉厉]
回复
沉冰浮水 沉冰浮水 发布于 2014-12-12 16:21:30  
https://www.wdssmq.com
[godsay2-人艰不拆]
回复
发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

网站分类

  • 订阅本站的 RSS 2.0 新闻聚合

搜索

本周旧文

wdssmq/blog-astro: 一个基于 Astro 的静态博客;

本质上,面临一个代码问题时,我们需要的是另一个人愿意为「你」的问题投入精力,并且有相应的技术知识。。

接上一条,Resilio Sync 换 Syncthing 感觉也是略大的工程。。Orz

去年 GoodSync 送了一年授权,然后也确实用上了;本来想着到期就换 Syncthing,结果前几天临期提醒,花 ¥381 续了三年 Orz,两者定位和使用姿势还是有些差别的。。更早是用 Resilio Sync 和 BCompare,但是前者内存占用太高,后者并不是自动同步的定位。。

2024 年了,姑且备份下嘟特存档。。

……,一个不知名的小众样式库 + 内联样式混写这种入坑姿势确实很有槽点,但是,「已经开始学」并且能够持续是绝对值得肯定的。。

在贴吧看过很多提问了,就有种错觉:好多人为了提一个问题专门注册了贴吧,问题本身可能得到有效回答,也可能没有(和提问的点及具体姿势有关。。但无论如何,之后就和注销了账号一样没有然后了,好像之后永远不用学相应的东西一样。。

《恶魔娃娃》

- 他们正研究你究竟是真正的大人,还是伪装成大人的小孩

- 我自己都研究很久了

乐高 DC 里,(基本就蝙蝠侠家,,年龄最小的那个无论是谁感觉人设都会变得一样 - -

所以,就感觉和祥林嫂一样,每天都需要向外「签到」自己的情绪感受,然而又并没有什么「需要」我这样的签到……

爱发电支持者

最新留言

友情链接