How to create friendly URL for page

Last post 06-14-2005 11:49 AM by tedblue. 1 replies.

Sort Posts:

  • How to create friendly URL for page

    06-13-2005, 1:48 PM
    • Member
      5 point Member
    • eriksalt
    • Member since 06-13-2005, 5:40 PM
    • Posts 1

    I have looked into the docs, but haven't found this yet, sorry if this is something I should know...

    I have a DNN site, and a page on that site that holds my blog, whose name is 'SimpleBlog', but the URL to this page is something like
    "http://blogs.xxxxx.com/SimpleBlog/tabid/61/Default.aspx"  I would like to access this page through some simpler page name like "http://blogs.xxxxx.com/SimpleBlog.aspx" is there any way to get DNN to give a simpler name like this to my page?

    Thanks,
    Erik

  • Re: How to create friendly URL for page

    06-14-2005, 11:49 AM
    • Member
      150 point Member
    • tedblue
    • Member since 06-12-2003, 6:20 PM
    • San Diego, CA
    • Posts 30
     eriksalt wrote:

    I have looked into the docs, but haven't found this yet, sorry if this is something I should know...

    I have a DNN site, and a page on that site that holds my blog, whose name is 'SimpleBlog', but the URL to this page is something like
    "http://blogs.xxxxx.com/SimpleBlog/tabid/61/Default.aspx"  I would like to access this page through some simpler page name like "http://blogs.xxxxx.com/SimpleBlog.aspx" is there any way to get DNN to give a simpler name like this to my page?

    Thanks,
    Erik



    We were able to accomplish this by adding a RewriterRule entry into the existing siteurls.config file (in the DNN root folder), as shown:

    <RewriterRule>
       <LookFor>.*/shoppingcart.aspx</LookFor>
       <SendTo>~/default.aspx?tabid=64</SendTo>
    </RewriterRule>

    The LookFor is a regular expression matching pattern - in this case, look for the page name "/shoppingcart.aspx" preceded by any other characters (.*). The SendTo is the replacement string, also a regular expression. In this case, use the default root (~) followed by the target page name and any parameters needed.

    You can also use part of the matched pattern in the resulting string, as shown here:

    <RewriterRule>
       <LookFor>.*/(.+)_training.*</LookFor>
       <SendTo>~/default.aspx?tabid=54&amp;category=$1</SendTo>
    </RewriterRule>

    This expression will take a URL that ends in "/asp.net_training.aspx" and the result will be the same URL ending in "/default.aspx?tabid=54&category=asp.net". See the .NET documentation for more about regular expressions. You can see this in action on our web site at www.bluestarlearning.com.

    This works in DNN 3.0.13 with or without Friendly URLs turned on. I saw a thread that indicated that this no longer worked in DNN 3.1 if Friendly URLs were off, but have yet to test this.

    Ted
Page 1 of 1 (2 items)