This project is read-only.

Remove "/page/" from URL

Topics: ASP.NET 2.0, Business Logic Layer
Jan 23, 2011 at 11:33 AM


how do I  remove /page/ from static page URLs?


Jan 25, 2011 at 9:35 AM

There's only a couple of changes really.

In the BE core, there is a Page.cs file.  In there, is a property called RelativeLink.  In BE 2.0, it looks like this:

public string RelativeLink
		var theslug = Utils.RemoveIllegalCharacters(this.Slug) + BlogSettings.Instance.FileExtension;
		return string.Format("{0}page/{1}", Utils.RelativeWebRoot, theslug);

You can remove page/ from that.

The 2nd part is in UrlRewrite.cs (also in the BE core) in the /Web/HttpModules folder.  In there, it's checking to see if the URL contains /page/.  The code looks like:

else if (url.Contains("/PAGE/"))
	RewritePage(context, url);

This part is a little trickier.  That code probably needs to be moved a little lower down, and if none of the other IF statements make a match, then you could try searching thru the pages to see if there's a matching page name.  RewritePage() checks for a page, and only does something if a page is found.  So you might even be able to move that code above down to the bottom, so it looks like:

	RewritePage(context, url);

Untested ... but it might work like that.  After making these changes, you will need to recompile the BE core to produce a new BlogEngine.Core.dll file ... which goes into the /bin directory.

Jan 25, 2011 at 9:45 AM
Edited Jan 25, 2011 at 9:47 AM

Thank you. I'll give it a go.

For now I'm using rewriter, because I have only few "static" pages and I'm doing something like this.


<add name="Some page" 


Not pretty, but it works   :)

It would be great if you could get rid of /page/ and /post/ by version 3.0.

I'm using BE as tiny CMS for a project and it would be great if this could be implemented   :)

Oct 13, 2011 at 8:54 PM

Good stuff... but still having trouble with it.

Has anyone figured out how to remove "page" from the URL for BE 2.5?

I'm having a really hard time with this as I'm not a c# guy... not sure where to put the code Ben talks about in 2.5... there's a bunch of other code down there at the end. Could someone please show exactly how the code should be?



Oct 15, 2011 at 7:31 PM
Edited Oct 24, 2011 at 6:34 PM

Looking for this too.


Want to remove [Page/Posts] from URL and also the .aspx  extension for BE 2.5

Java Blog

Oct 16, 2011 at 2:59 AM

I almost got this working... but it's killing the formatting of my page.

The URLs work fine, "page/" is removed, but the css seems to go missing?

The weird thing is that the HTML source between the original site and the modified site are the same.

Here's how I have the code in URLrewrite.cs (just the bottom section)...

 if (!skipRewrite)
                        // remove the subfolder portion.  so /subfolder/ becomes /.
                        rewriteUrl = new Regex(Regex.Escape(blogInstance.RelativeWebRoot), RegexOptions.IgnoreCase).Replace(rewriteUrl, Utils.ApplicationRelativeWebRoot);

                        context.RewritePath(rewriteUrl + rewriteQs, false);

////////////// code modified here ///////////////////
                    RewritePage(context, url);
////////////// end modified code ///////////////////


Not sure why the css is affected?

Oct 16, 2011 at 5:31 AM

Ok, so there is a file called Web/Controls/BlogBasePage.cs which controls the css.

Because the "page/" reference has been removed from the URL, and the css is based off of a relative link, that's why the css was messed up.

I know there is a better way to do this... I just don't know how, so I simply hard coded the http file location to the css file like this in the "protected virtual void CompressCss()"

 //c.Attributes["href"] = url.Replace(".css", string.Format("{0}.css", BlogSettings.Instance.Version()));
                c.Attributes["href"] = "";

That took care of that issue, which seems to be ok so long as I don't want to change themes. Not a perfect solution by any means.

Anyway, with that kinda solved, there is another side-effect that is really problematic. And that is that the ADMIN section gets all screwed up when the modifications are made to the URLrewrite.cs

Most of the editable sections now have no data displaying and some of the pages crash.

Not sure how to fix that issue, but I'll keep looking.

Anyone else figured this out yet?

Would really like to hear from the developers please for a proper solution for removing "page/" from the URLs.




Oct 16, 2011 at 8:58 PM


Oct 16, 2011 at 9:26 PM

Slider72  :   What files did you change to get it to work? In BE 2.5


I edited: page.cs


 var theslug = Utils.RemoveIllegalCharacters(this.Slug)+ BlogConfig.FileExtension;
                return string.Format("{0}{1}", Utils.RelativeWebRoot, theslug);


Then the UrlReWrite.cs


 if (!skipRewrite) {
                        // remove the subfolder portion.  so /subfolder/ becomes /.
                        rewriteUrl = new Regex(Regex.Escape(blogInstance.RelativeWebRoot), RegexOptions.IgnoreCase).Replace(rewriteUrl, Utils.ApplicationRelativeWebRoot);

                        context.RewritePath(rewriteUrl + rewriteQs, false);
                                RewritePage(context, url);




Like you did but its not working.


it makes the url /root/pagename.aspx


But when you go to it its not found.


But when you add /page/  to it works.

Oct 16, 2011 at 9:30 PM

Simple mistake had the return;


in the wrong place.


Its working fine now with no CSS troubles so far.

Oct 16, 2011 at 10:12 PM

Well I am stuck with the css problems


Why does /page  effect the css?

Oct 17, 2011 at 5:18 PM
Edited Oct 17, 2011 at 5:25 PM

I really need to be able to remove the [page/post] and the extension .aspx  from only all posts and pages.

I have a wordpress website that I am moving to BlogEngine.Net  the wordpress site  does not have /pages or /posts

in the url and also its extension less.


I don't won't to move it to with the /page /post and .aspx in the url.


Trying to keep the orginal url the same.


Also SEO wise  making the shorter helps with search engine rankings.

Oct 17, 2011 at 8:04 PM

Also found out that the folder /page   have to be there.


Tried editing it to just /p   same issues with the css and etc.


So for some reason "page"  has to be there for the css and etc to work.


I thought it might be just a directory/folder issue but its not its the name issue "page".

Oct 17, 2011 at 11:16 PM

Hey Keith,

I need the same thing you are looking for.  For SEO purposes I need the public facing blog url's to be as focused as possible and would like them to not include the /post/ or /page/ directories or the .aspx extension.

I just got done doing similar enhancements to my core ecommerce platform (non blog engine based), and am now looking to find a way to do the same for blogengine.  I see a couple issues off the bat however. 

If the incoming url doesn't contain /post/ or /page/ blog engine is probably gonna need some way to tell which it is.  A post or a page.  My initial inclination is to make all request that are

based on the root be posts.  e.g. /my-cool-post-1234 where 1234 is the postrowId in the mysql database I'm using.  Then perhapse create a setting that allows us to list the various directories

that contain "pages".  That way, if a request comes in for one of these directories it can be handled as a page. 

Another challenge with is that uses guids as the main way to id a post, and guids are long and ugly for url use which is why I'd rather use postrowid, but that creates some issues

with supporting the xml data provider.


Oct 18, 2011 at 12:23 AM

I was re-reading SEO URL tips from Google.

I think a better Idea is to have the URL like these:[Page/Post]

Like this:


So have the main catogry of the [post/page] as the first directory then the file name right after it.

In the Edit [Page/Post]  Have an additional check mark need to the [Catogories] thats for use as directory in url.


Then the Edit pages would need the Catogories  selection added to it too.

For the url can only select one Cat for the URL  but can have Parent/Child Catogories.  



Also User can still keep the old format if wanted just make a Cat for [Post/Page] and have that

defaulted to be checked.

So URL would be

This would follow Google Suggestions for proper URL Formating:



Simple-to-understand URLs will convey content information easily
URLs are displayed in search results

(1) A URL to a page on our baseball card site that a user might have a hard time

URL 1:

URL 2:

(2) The highlighted words above could inform a user or search engine what the
target page is about before following the link.

(3) A user performs the query [baseball cards]. Our homepage appears as a result,
with the URL listed under the title and snippet.
Creating descriptive categories and filenames for the documents on
your website can not only help you keep your site better organized,
but it could also lead to better crawling of your documents by
search engines.

Also, it can create easier, "friendlier" URLs for those
that want to link to your content.

Visitors may be intimidated by
extremely long and cryptic URLs that contain few recognizable words.

URLs like (1) can be confusing and unfriendly.

Users would have a hard time reciting the URL from memory or creating a link to it.

Also,users may believe that a portion of the URL is unnecessary, especially
if the URL shows many unrecognizable parameters.

They might leaveoff a part, breaking the link.

Some users might link to your page using the URL of that page as the
anchor text.

If your URL contains relevant words, this provides
users and search engines with more information about the page
than an ID or oddly named parameter would (2).





Oct 20, 2011 at 7:33 PM

Thanks Kbdavis07 - these are great suggestions.  Sorry to be slow thanking you.  I got caught up in a different blogengine enhancement (RelatedPosts widget).

Anyway, I wanted to make sure I thanked your for your thoughts on this one.


Oct 20, 2011 at 8:16 PM

Thanks :)