+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Using IIS URL Rewrite to force all lower-case URLs breaks Sitefinity backend

Using IIS URL Rewrite to force all lower-case URLs breaks Sitefinity backend

7 posts, 0 answered
  1. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    11 Feb 2013
    Link to this post

    I followed the instructions on SF documentation for Using URL Rewrite for SEO.  The rule to force all URLs to lower-case DOES NOT WORK correctly.  The backend breaks.  Trying to edit any page (under PAGES in backend) results in a nasty client-side (web browser) error when trying to publish the page.  Something about character set not being equal to published character encoding, blah blah blah.

    This  is the rule I added, per Sitefinity documentation:

    <rule name="Convert URLs to lower case" enabled="true" stopProcessing="true">
        <match url="[A-Z]" ignoreCase="false" />
        <conditions>
            <add input="{REQUEST_URI}" pattern="^/sitefinity/" negate="true" />
        </conditions>
        <action type="Redirect" url="{ToLower:{URL}}" redirectType="Permanent" />
    </rule>

    After I commented-out the entire rule, my webpages were able to be published correctly. I believe the error stems from the fact that, once a page is in edit mode, the URL is something like

    http://mysite.com/pagename/action/edit

    It seems that the "action/edit" must not be lower-case (really, Telerik, really?).  The rule does not account for those exceptions (although it does try to make an exception for "/sitefinity/" but that's not good enough).

    I can imagine that can be fixed by adding some additional exceptions to the URL Rewrite rule, but I'm not an expert on those, so I will not attempt to do it myself.  Plus, this was in SF documentation, so if you ask me, this is a bug and a failure on Telerik's part to fully test something before releasing instructions.

    So, I'm asking Telerik to please update your documentation on this, and let us know how to PROPERLY add a rewrite rule for forcing lower-case URLs while NOT breaking your backend.  I understand it is not your job to teach us how to use IIS URL Rewrite, but it IS your job to tell us what can and can't be accessed by lower-case URL in backend.

  2. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    11 Feb 2013 in reply to Marko
    Link to this post

    There's a big laundry list of SEO url things that need documenting\fixing...it'd be nice if it just worked a bit nicer out of the box :/

    Anyway, this is what I use...always a WIP though.

     

    <rules>
            <clear />
            <rule name="LowerCaseRule1" stopProcessing="true">
              <match url="^(Sitefinity/)" ignoreCase="true" negate="true" />
              <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{URL}" pattern="[A-Z]" ignoreCase="false" />
                <add input="{URL}" pattern="\.axd" negate="true" />
                <add input="{URL}" pattern="\.xamlx" negate="true" />
                <add input="{URL}" pattern="\.ashx" negate="true" />
                <add input="{URL}" pattern="\.asmx" negate="true" />
                <add input="{URL}" pattern="\.xap" negate="true" />
                <add input="{URL}" pattern="bundles" negate="true" />
                <add input="{REQUEST_FILENAME}" pattern="SFRes" negate="true" />
              </conditions>
              <action type="Redirect" url="{ToLower:{URL}}" redirectType="Permanent" />
            </rule>
            <rule name="RemoveTrailingSlashRule1" stopProcessing="true">
              <match url="(.*)/$" />
              <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" pattern="(.*?)\.svc$" negate="true" />
                <add input="{REQUEST_FILENAME}" pattern="bundles" negate="true" />
              </conditions>
              <action type="Redirect" url="{R:1}" />
            </rule>
          </rules>

     

  3. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    12 Feb 2013
    Link to this post

    Thanks, Steve!  I think this works, at least for the problems I was seeing before.  I appreciate your input.

    I just wish Telerik was more proactive and thorough with their documentation.  Probably my biggest gripe with them, for the last 5 years that I've been their customer.  :-(

    On the subject of rewrite rules, I've just put in place a rule to redirect requests to domain root to a specific home page (in order to enforce consistent SEO and Google Analytics reporting for the home page).  I want to make sure this doesn't break Sitefinity like the other one did.  Any problems with this:

    <rule name="Home Page Redirect" enabled="true" stopProcessing="true">
        <match url="^$" />
        <action type="Redirect" url="home" redirectType="Permanent" />
    </rule>

    The idea is to redirect something like http://www.mysite.com to http://www.mysite.com/home. 

    The other option was to redirect the other way around (when www.mysite.com/home is requested redirect to www.mysite.com but I was getting inconsistent behavior across browsers--IE was leaving a trailing slash, even though I have a rule for that, while FF was doing it without trailing slash).  So I decided it might be easier to redirect to "home" instead.

  4. Mark
    Mark avatar
    147 posts
    Registered:
    01 Jun 2010
    12 Feb 2013 in reply to Marko
    Link to this post

    Patrick Dunn has posted some great tricks in his blog reguarding SEO in sitefinity:

    http://patrickdunn.me/blog/posts/2012/11/02/seo-in-sitefinity-1-different-url-casings
    http://patrickdunn.me/blog/posts/2012/11/05/seo-in-sitefinity-2-avoiding-duplicate-homepage-urls
    http://patrickdunn.me/blog/posts/2012/11/06/seo-in-sitefinity-3-remove-www-from-url
    http://patrickdunn.me/blog/posts/2012/11/21/seo-in-sitefinity-4-remove-default-aspx-from-all-requests

  5. Mark
    Mark avatar
    147 posts
    Registered:
    01 Jun 2010
    15 Jan 2014
    Link to this post
    The URL rewrites seem to break the new Google Analytics module in 6.3. Has anyone figured out a work-around yet?

    These are the rules I'm using: 

    http://www.sitefinity.com/documentation/documentationarticles/installation-and-administration-guide/create-a-project/creating-and-running-projects-on-iis/using-url-rewrite-for-seo
  6. Mark
    Mark avatar
    147 posts
    Registered:
    01 Jun 2010
    15 Jan 2014 in reply to Mark
    Link to this post
    If anyone else runs into this, you need to add a pattern for "RestApi" to the LoweCaseRule

    <rule name="LowerCaseRule1" stopProcessing="true">
              <match url="^(Sitefinity/)" ignoreCase="true" negate="true"/>
              <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{URL}" pattern="[A-Z]" ignoreCase="false"/>
                <add input="{URL}" pattern="\.axd" negate="true"/>
                <add input="{URL}" pattern="\.xamlx" negate="true"/>
                <add input="{URL}" pattern="\.ashx" negate="true"/>
                <add input="{URL}" pattern="\.asmx" negate="true"/>
                <add input="{URL}" pattern="\.xap" negate="true"/>
                <add input="{URL}" pattern="bundles" negate="true"/>
                <add input="{REQUEST_FILENAME}" pattern="SFRes" negate="true"/>
                <add input="{REQUEST_FILENAME}" pattern="RestApi" negate="true"/>
              </conditions>
              <action type="Redirect" url="{ToLower:{URL}}" redirectType="Permanent"/>
            </rule>
  7. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    30 Jun in reply to Steve
    Link to this post

    Thanks Steve this was a huge help. 

    Has anything changed since this post in terms of what Sitefinity does out the box, or perhaps something you now do differently? 

7 posts, 0 answered