| Posted By Wayne at Sunday, October 16, 2011Category:Programming»Web Development»Misc |
I've successfully transferred my website to winhost, now the architecture is IIS 7.5 + ASP.NET 4.0 + SQL Server 2008 R2 + HTML5, this blog post is a summary about URL Rewrite Rules used by WayneYe.com. RESTful URL for blogsBlog posts are absolutely the soul of a blog website, comparing with blog URL format: "/yyyy/MM/{Blog_Title}", I actually prefer "/Blog/{Blog_Title}", more simpler/shorter, in additional and more important, generally speacking,valuable content is valuable no matter when it was posted, for example, a developer is searching C# covariance & contravariance articles, two articles separately posted on 3/28/2010 and 1/25/2011 won't make ANY difference for this developer. Now that all my blogs take URI format like: "http://WayneYe.com/Blog/{Blog_Title}", it is so called "Permalink", I must ensure there is no duplicate blog titles (not case sensetive even if I can enable URL case sensitive through IIS manager, it would be quite confuse to the end user), so actually in my backend blog post page I did a DB check for existing blog titiles:) Here is the Blog URL rewrite config XML stored in my Web.config: <rule name="BlogPermalinkRewrite"> Navigate LinksThat's so simply, rewrite to an ASPX page under a matched directory: <rule name="NaviAlbum" patternSyntax="ExactMatch"> Category/Archive/TagThese three type of URLs are similar, but makes a log of sense to a website comforming REST. <rule name="CategoryRewrite"> Define Atom/RSS feeds MIME typeWayneYe.com programmatically generates Atom/RSS feeds in plain XML format, the two XML file exists phisically under Feeds/Atom/Atom.xml and Feeds/RSS/RSS.xml, other then rewrite URL for both, one more important thing to do is override the "text/xml" MIME type to follow the standard:
To achieve this needs a little bit more work: intercepting response stream and overriding server variable, this requires adding an "Allowed Server Variables": this is done by the following steps: 。。。 |




