Loading...

All project content is available for reading, but you need to be a member of the project for Subversion checkout of source code, or to create/modify any information.
Login if you are a member. Apply here to request membership (open to all).

Making Waves Mobile Url Rewriter

Making Waves Mobile Url Rewriter is a friendly Url engine, which translates incoming Urls so they point to specific templates based on configured rules. Most useful scenario is providing device-specific versions (e.g. for mobile devices) using different templates while retrieving data from a single data source (Page Data).

This flexible solution is editor-friendly because only one form for each page must be filled and it becomes a source for different page templates.

How it works

To illustrate how it works, consider differences between using default friendly Url provider and Making Waves’ rule based Url provider

For default friendly url provider

  • /Articles/Website-Launch url is translated to /Templates/Articles/NewsTemplate.aspx?id=1234
  • /Articles/Website-Launch/Mobile returns 404 error

For rule based url rewrite provider with configured mobile rule (as suffix rule)

  • /Articles/Website-Launch is translated to /Templates/Articles/News.aspx?id=1234
  • /Articles/Website-Launch/Mobile is translated to /Mobile/Templates/Articles/News.aspx?id=123&Rule=”Mobile
  • /Articles/Website-Launch/Lite is translated to /Lite/Templates/Articles/News.aspx?id=123&Rule=”Lite” (e.g. Lite/Full website version like MSDN)

Additionaly further template selection can be made based on User Agent (sent by browser), so for example IPhone users can be served a different version then other mobile devices, which may have low resolution displays.

Note: Url suffix (“Mobile”) and path for templates (“/Mobile/Templates/”) are examples and can be configured in web.config

You can check how it works in production at Making Waves’ website. Additionaly if you visit this website from mobile device you will be automatically redirected to mobile version.

Rule selection

When client tries to access any Url rule based rewriter, selects rule which will perform further processing. All rules are probed for matching and first, which accepts url, is responsible for template selection.

In an example below, third rule matches url and then selects the fourth template. After page is rendered, the rule is also responsible for transforming non-friendly urls into corresponding friendly urls for this rule from page markup.

Features

  • Configurable in web.config and programmatically
  • Extensible rule selection engine
  • Translates urls in rendered page using rule choosen to select template

Supported rules

Download

Sample Configuration

In web.config

<configSections>
  <section name="makingWaves.urlRewrite" type="MakingWaves.Common.EPiServer.UrlRewriting.Configuration.UrlRewriteSection, MakingWaves.Common.EPiServer.UrlRewriting"/>
  ...
</configSections>
<makingWaves.urlRewrite>
  <rules>
    <add name="MobileRule" 
          type="MakingWaves.Common.EPiServer.UrlRewriting.AgentBasedSubDomainMatchingUrlRewriteRule, MakingWaves.Common.EPiServer.UrlRewriting"
          subDomain="m."
          rootPath="MobilePath/Regular">
      <ruleProperties>
        <add propertyType="agent" agentPattern=".*IPhone.*" pathSuffix="MobilePath/IPhone"/>
      </ruleProperties>
    </add>
  </rules>
</makingWaves.urlRewrite>

In episerver.config

<episerver>
  <urlRewrite
      defaultProvider="RuleBasedUrlRewriteProvider">
    <providers>
      <add name="RuleBasedUrlRewriteProvider"
            description="My provider supporting multiple templates"
            innerProvider="EPiServerFriendlyUrlRewriteProvider"
            type="MakingWaves.Common.EPiServer.UrlRewriting.RuleBasedUrlRewriteProvider,MakingWaves.Common.EPiServer.UrlRewriting"/>
       <add name="FriendlyUrlRewriteProvider" decription="..." type="..."/>
      ...
    </providers>
  </urlRewrite>
</episerver>

Additionally, if you want a mobile client to be redirected to a proper version of a page consider using the following snippet using extension method GetLinkUrlByRule:

if (HttpContext.Current.Request.Browser.IsMobileDevice)
{
    this.Response.Redirect(CurrentPage.GetLinkUrlByRule("MobileRule"));
}

Extensibility

In order to create your own rule you must implement IUrlRewriteRule or use BasicUrlRewriteRule base class. Take a look at implementation of provided rules for further details.

Support

Tickets for this component:

#237
Error in link to mobile example site
#254
Language support and url rewriter
#266
Sub domain and caching

Ask a question

Requires login.


Report a bug

Requires login.


Add a feature request

Requires login.


Requirements

Runtime:

  • EPiServer CMS 6
  • .NET 3.5 and 4.0

If you want to change and compile the source code:

  • Visual Studio 2010

Contributed by

Andrzej Zapotoczny (andrzej.zapotoczny _mail_at_ makingwaves.pl), Mirosław Jedynak (miroslaw.jedynak _mail_at_ makingwaves.pl) from Making Waves (http://www.makingwaves.com)

Attachments