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

Forums / Developing with Sitefinity / Advanced URL Rewriter

Advanced URL Rewriter

9 posts, 0 answered
  1. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    22 Sep 2010
    Link to this post
    Hello,

    I've asked a similar question to this previously but wasnt able to find a complete solution. I'm not trying to achieve extensionless urls, however I do need to be able to acheive the following:

    - Lowercase urls (an all pages and modules)
    - Fix trailing slashes
    - Force non www to www site

    I have been pointed to the developer manual, but all three of the above scenarios should result in a 301 redirection rather than a rewrite, which i dont think the SiteFinity URL Rewriter covers.

    Could anyone please advise whether this functionality is indeed possible from within SiteFinity? For example i can see that it is possible to set lowercaseUrls on the cmssitemapprovider, but that itself does not prevent someone manually typing a hyperlink which includes the uppercase version, and again it doesnt stop search engines from possibly seeing two versions of the same url.

    If this functionality is not available, could anyone please advise as to whether there are any problems using the IIS Rewrite module - I'm concerned as to whether employing this technique means that each request will be processed by both the IIS Rewrite module, and then subsequently the Sitefinity url rewrite module.

    Thanks in advance
    higgsy
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Sep 2010
    Link to this post
    Hello Alastair,

    You can achieve Lowercase urls (an all pages and modules) and Fix trailing slashes with Advanced Url Rewrite which setup and engine basis is explained in our UserManual page 195. it works in similar way as ASP.NET UrlRewiting. It is better to change only public urls, not backend urls which may result in some issues.

    Force non www to www site - this is not possible without redirect - the status code here will be 301.


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    22 Sep 2010
    Link to this post
    Hi Ivan,

    As always, thanks for your quick response.

    Ok perhaps I am missing something, adding lowercaseUrls to the sitemap provider section will not force a 301 redirect will it? Forcing lowercase urls, fixing trailing slashes and www redirection should ALL force a 301 redirect, but i dont see anything in the user manual regarding 301's.

    I can get a rule working very simply doing the following:

    <telerik>
        <urlrewrites ignoreCase="true">
            <rule>
                <url>/NEWS.aspx</url>
                <rewrite>/news.aspx</rewrite>
            </rule>
        </urlrewrites>

    But this doesnt acheive the right result because i can still access:

    /NEWS.aspx
    /NeWs.aspX
    /nEwS.aspx

    Each of these urls just return a http 200 response, everythings ok - but thats not the desired result. They have to result in 301's and I dont see anything in the user manual regaridng this.

    Have i missed something?

    Thanks again
    higgsy
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Sep 2010
    Link to this post
    Hi Alastair,

    The AdvancedUrlRewriter has a mode -PermanentRedirect which you can set in urlrewrites section. Your rules are not correct. When the url in the "LookFor" contains special chars like dots, they have to be escaped with back slash. We use the same rules as ASP.NET Rewriter and Regular expression rules.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    22 Sep 2010
    Link to this post
    Ok great - that sounds perfect.

    Can you point me in the direction of some documentation, the PermenantRedirect is not mentioned in the user/developer manuals.

    thanks again
    higgsy
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Sep 2010
    Link to this post
    Hi Alastair,

    When you use PermanentRedirect mode this means that the CmsHttpModule will make "Response Redirect".
    For the current Http response we set its status property to "301 Moved Permanently". Then we call AddHeader method where we pass the resulved url as value. Finally the outputted buffer is sent to the client.

    You can also take a look at



    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    22 Sep 2010
    Link to this post
    Hi Ivan,

    I'm not sure i understand what you are suggesting.

    I dont see how adding additional urls to each of the pages can force a lowercase. I would have to list every possible variation that a user could type in.

    For the trailing slashes and forcing of www i have to be able to put a permenantredirect tag in the web.config file, otherwise im not sure i understand how you are suggesting this could possibly work????

    thanks
    higgsy
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Sep 2010
    Link to this post
    Hi Alastair,

    You do not need to know each combination, you have to lower the letters themselves.You could also use HttpModule/Handler and get the url as string, then use .ToLower() and make response redirect in BeginRequest from the current context(HttpContext.Current).

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    22 Sep 2010
    Link to this post
    Hi Ivan,

    Are you suggesting that i create e.g. a page called news.aspx, and then add another URL which is again news.aspx?

    Or are you actually saying that to fix lowercase / trailing slashes and non www i actually need to write a handler?

    Thanks
    higgsy

Register for webinar
9 posts, 0 answered