Minor BlogEngine Customizations

Minor BlogEngine Customizations

by MGD King October 18, 2012

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!

Add comment


  • Comment
  • Preview
Loading

Who Is MGD King?

MGD KingA lot of people ask me what does MGD King mean? Well, it was a nickname given to me because I used to drink large quantities of Miller Genuine Draft. Someone mentioned to me that I was the King of MGD, and so it stuck.

I'm On Twitter!

Note: For Customization and Configuration, CheckOut Recent Tweets Documentation
 
 

Latest Comments

Comment RSS