I have this Url
/news/2015/08/08/news-title
I want to write rewriterule to redirect to the same url but without 0 for month or day so the final url will be like this
/news/2015/8/8/news-title
Here you go:
<rule name="DateRule" stopProcessing="true">
<match url="news/(\d*)/0(\d)/0(\d)/(.*)" />
<action type="Redirect" url="news/{R:1}/{R:2}/{R:3}/{R:4}" redirectType="Permanent" />
</rule>
I've done it as a Temporary Redirect (307) because it makes testing easier. To do it as a Permanent (301) one change it to redirectType="Permanent"
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.