I needed to make some changes to how BlogEngine.net serves up pages and posts. Basically, by default, links are like this:
blog-domain-name/page/page-name.aspx
blog-domain-name/posts/yy-mm-dd/post-title.aspx
I wanted to change them to look like this:
blog-domain-name/web/page-name.aspx
blog-domain-name/news/yy-mm-dd/post-title.aspx
I'm not a Visual Studio or .NET developer, I know enough about each to be dangerous really. So I started digging around in a couple of files with Visual Studio and foud out how to do it. All I have to do is edit the following:
Open the entire BlogEngine solution (BlogEngine.sln) and browse to BlogEngine.Core and then the Web/HttpModules subfolder. Open the UrlRewrite.csfile. Look for the line
url.Contains("/PAGE/")
and change it to whatever you want it to be. I'm going use bacon in my example so mine would look like
url.Contains("/BACON/")
Next, look for line
else if (urlContainsFileExtension && url.Contains("/PAGE/"))
and change the word PAGE to whatever you changed it to above. In my example it would be
else if (urlContainsFileExtension && url.Contains("/BACON/")).
Now, still in Visual Studio, browse to the Web subfolder and open the Page.cs file. Look for the line
return string.Format("{0}page/{1}", Utils.RelativeWebRoot, theslug);
and change the word page to match what you used above. Mine now looks like
return string.Format("{0}bacon/{1}", Utils.RelativeWebRoot, theslug);
and then I save the two files. You must rebuild your solution or else the changes won't take effect. Links to pages will now look like this:
blog-domain-name/bacon/page-name.aspx
You can also make changes to the Post.cs file and Category.cs file the same way. Just make sure that you edit the UrlRewrite.cs file as well. Pretty cool huh!
Latest Comments
- How To Reinitialize The Offline Cache in Windows 7 (17)
- Outlook 2016 Cannot Forward Attachments - KB4011626 Issue (20)
- Outlook 2016 Cannot Forward Attachments - KB4011626 Issue (20)
Comment RSSCharles Haven wrote: 2018 - this still works!! Thanks! [More]
Phil wrote: Thanks! We're having this issue as well. I'... [More]
MGD King wrote: That's bizarre. I've installed the hotfix ... [More]