Friendly Url Rewriter that excludes certain pagetypes

Vote:
 
Does this exist out of the box, or do I have to write my own? If the subject is unclear I want the friendly url to exclude pages that are of a certain page type.
#26484
Dec 08, 2008 15:02
Vote:
 
Hi Ulrik.

I had the same problem some days ago. I ended up with this in the Global.asax.cs file:

 protected void Application_Start(Object sender, EventArgs e)
  {
     // Initialize the HtmlRewriteInit
     HtmlRewriteToExternal.HtmlRewriteInit += HtmlRewriteToExternal_HtmlRewriteInit;
  }

  private static void HtmlRewriteToExternal_HtmlRewriteInit(object sender, HtmlRewriteEventArgs e)
  {
     // Hock on to the HtmlReWritingUrl
     FriendlyHtmlRewriteToExternal module = sender as FriendlyHtmlRewriteToExternal;
     if (module != null)
     {
       module.HtmlRewritingUrl += Module_HtmlRewritingUrl;
     }
  }
  
  private static void Module_HtmlRewritingUrl(object sender, UrlRewriteEventArgs e)
  {
     // Cancel the Rewrite behavior if the url contains pagenametemplate.aspx
     string path = e.Url.Path.ToLowerInvariant();
     e.Cancel = path.Contains("pagenametemplate.aspx");
  }

You have two events in the FriendlyHtmlRewriteToExternal. HtmlRewritingUrl that happens before the rewriting process starts and HtmlRewroteUrl that happens after the rewriting process is done. Hope this helps!

Br, Tore Gjerdrum

www.epinova.no 
#26486
Dec 08, 2008 15:27
Vote:
 

Thanks for the reply but it's not exactly what I'm looking for. This will cancel the complete rewrite for a certain pagetype. I want to just exclude certain pagetypes from the rewrite, like this.

 /en/stuff/startpage/article

Let's say that the page "stuff" is of a certain pagetype I want to exclude that from the rewrite to make it

 /en/startpage/article

#26497
Dec 09, 2008 0:04
Vote:
 

Hi Ulrik.

I don`t think that there is an out of the box solution for that i EPiServer. I think you have to write your own logic for that case. Maybe you could hock on to the HtmlRewritingUrl event and do your own rewriting, or you could hock on to the HtmlRewroteUrl and do you modifications after the rewrite procedure is finished.

Ted Nyberg wrote a great blog about implementing your own rewrite provider. Maybe you can pick up some tips here(http://labs.episerver.com/en/Blogs/Ted-Nyberg/Dates/112276/7/Implementing-a-custom-URL-rewrite-provider-for-EPiServer/).

There is also an page in the SDK, http://sdk.episerver.com/library/cms5/Developers%20Guide/Friendly%20URL.htm, that can be of great use. 

 

BR, Tore Gjerdrum 

#26502
Dec 09, 2008 8:42
Vote:
 

Have you had a look at UnTouchedPaths?

 

http://labs.episerver.com/en/Blogs/Ted-Nyberg/Dates/112276/112277/Disable-URL-rewriting-for-specific-URLs/

#26518
Dec 09, 2008 16:24
Vote:
 

Hi Thomas.

That would defiantly be a better solution in my case. Thanks for the tip!

Br, Tore Gjerdrum 

#26524
Dec 09, 2008 22:08
Vote:
 
Thanks, but none of the solutions fits my needs. I've put this on ice and will try to come up with a better tree-structure instead. I could ofcourse rewrite the urlrewriter but I figure there's alot of things going on in the native urlrewriter like exceptions for vpp and so on, to much hassle.
#26555
Dec 10, 2008 23:20