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

Forums / General Discussions / Using urlrewrites with trailing and non trailing slashes

Using urlrewrites with trailing and non trailing slashes

2 posts, 0 answered
  1. Steven Harrap
    Steven Harrap avatar
    13 posts
    Registered:
    26 Sep 2012
    19 Jan 2011
    Link to this post
    Hi

    I am trying to implement the <urlrewrites> functionality in the config.inc. I need to be able to handle links such as "www.xyz.com/contactus" as well as w"ww.xyz.com/contactus/". I have read http://www.sitefinitywatch.com/blog/09-01-08/URL_Rewriting_with_Sitefinity_s_AdvancedUrlRewriter.aspx and successfuly got "www.xyz.com/contactus/" to work but not www.xyz.com/contactus.

    This is the 404 being handled (this appears to be required)
    <httpErrors>
          <remove statusCode="404" subStatusCode="-1" />
          <error statusCode="404" prefixLanguageFilePath="" path="/sf404.aspx" responseMode="ExecuteURL" />
        </httpErrors>

    This is an example rule. Situations where the user or link does not place a "/" after contactus do not work.
    <rule>
            <url>/contactus</url>
            <rewrite>/some-sub-folder/contact.aspx</rewrite>
          </rule>

    I have tried alteratives such as:
     - making a custom HttpModule to add missing trailing slashes but this does not work on the production server for reasons that I failed to understand.
    - making a custom 404 page to catch the lack of a trailing slash, add it back and try redirecting (yuck!) but that has failed as well. Infact trying to make a custom 404 page work correctly in general failed as well.

    Does anyone have a silver bullet for this trailing slash problem? It's driving me nuts!!!

    Many thanks,
    Steven.
  2. Steven Harrap
    Steven Harrap avatar
    13 posts
    Registered:
    26 Sep 2012
    20 Jan 2011
    Link to this post
    Ok after nights sleep and more work I have a working solution that address my trailing/non-trailing slash problem. Again I followed the instructions here:
    http://www.sitefinitywatch.com/blog/09-01-08/URL_Rewriting_with_Sitefinity_s_AdvancedUrlRewriter.aspx


    Had to keep this and ensure that I created a page in sitefinity called /sf404
    <httpErrors
          <remove statusCode="404" subStatusCode="-1" /> 
          <error statusCode="404" prefixLanguageFilePath="" path="/sf404.aspx" responseMode="ExecuteURL" /> 
        </httpErrors>

    I have had to remove the page extension. This has caused me to have fix up templates, cross site links and other situations where the ".aspx" was included in strings, settings etc.
    <cms defaultProvider="Sitefinity" pageExtension="" projectName="xyz" disabled="false" pageEditorUIMode="Overlay">

    A mix of alternate page urls and the urlrewrites has dealt most incoming links involving the inclusion or lack of trailing slashes. 

    This seems to be the only way I can get it to work. All in all it was a lot of stress and effort to deal with the trailing slash situation.

    Cheers,
    Steven.
2 posts, 0 answered