Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Martin Peter Hanke 5 posts 25 karma points
    Aug 16, 2010 @ 11:17
    Martin Peter Hanke
    0

    URL Rewriting

    Hi there

    we would like to implement an extension which generates URLs from a database field. (Hopefully this is the right place to post this question... Sorry in advance if not...)

    Example : News

    We would like to have a link like this:

    www.myhost.com/News/title_of_news.aspx

    Where /News would be the news list and title_of_news.aspx would be the same detail view page.

    Maybe this can also be done in the configs - any hint is highly welcome...

    Best Regards

    Martin

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Aug 16, 2010 @ 11:28
    Stefan Kip
    0

    Soo... What is you question exactly?

    Can't you just create a node called 'News' with news items underneath it?
    Then you automatically get URL's like /News/Some-news-message.aspx

  • Martin Peter Hanke 5 posts 25 karma points
    Aug 16, 2010 @ 11:35
    Martin Peter Hanke
    0

    Hi

    exactly at this point the problem has it's root...

    The news are feed from a different DB. The listing page reads the db (an UserControl) and redirect with paramter to the detail view page.
    I would like to have a nice URL instead of the ID. The news are not kept in the umbraco DB...

    I'm looking for some kind of url rewriting like typo3 does - it takes the news title and creates the url thereof.

    But at the moment I can't find a hook or method, where I can hook in and create an nice url which is then translated to the right news ID on the news-detail page.

    I hope this explanation makes it more clear than my first request...

     

  • Sascha Wolter 615 posts 1101 karma points
    Aug 16, 2010 @ 12:01
    Sascha Wolter
    0

    Hi Martin,

    you can create a custom rewrite rule in the UrlRewriting.config file like so:

            <add name="newsredirect" 
              virtualUrl="^~/news/(.*).aspx" 
              rewriteUrlParameter="ExcludeFromClientQueryString" 
              destinationUrl="~/news.aspx?id=$1" 
              ignoreCase="true" />

     

    On the news page you then have a usercontrol that looks for the id,
    - if no id: connect to external db and list news items
    - if id provided: get news item from external db and display

    Hope that is what you are looking for,
    Sascha

  • Martin Peter Hanke 5 posts 25 karma points
    Aug 16, 2010 @ 12:07
    Martin Peter Hanke
    0

    almost - but it looks close to what I'm looking for.

    To put it right:
    you suggest creatîng a link in the News-List module like so: news/my_funky_news_title.aspx

    The deails page would then receive an url param called id which holds "my_funky_news_title" - right?

    this would then look like this: news/detailpage.aspx?id=my_funky_news_title

    Do I understand this correctly?

    if this is your suggestion, then I guess this is what I'm looking for :-)

    Martin

  • Sascha Wolter 615 posts 1101 karma points
    Aug 16, 2010 @ 12:16
    Sascha Wolter
    0

    Hi Martin,

    you are absolutely right in your assumption. Obviously you would have to identify the news items by name rather than id if you don't want to put the id into the link as well like

    /news/####-my_funky_news_title.aspx (see the link displayed for this forum post!) or
    /news/my_funky_news_title_####.aspx or
    /news/my_funky_news_title.aspx?id=#### (in which case you can just ignore the name, however is probably not at all what you want)

    Cheers,
    Sascha

  • Martin Peter Hanke 5 posts 25 karma points
    Aug 16, 2010 @ 12:23
    Martin Peter Hanke
    0

    Thanks alot!

    this is the perfect solution for my needs!

    the first 2 suggestions

    "/news/####-my_funky_news_title.aspx (see the link displayed for this forum post!) or
    /news/my_funky_news_title_####.aspx or"

    are perfect and would ease my life - but I'm a dummy in RegEx - could you help me out with this one?
    How do the RegEx need to look like?

    Thanks in Advance

    Martin

  • Sascha Wolter 615 posts 1101 karma points
    Aug 16, 2010 @ 12:40
    Sascha Wolter
    0

    Hi Martin,

    give this a try:

    <add name="newsredirect" 
              virtualUrl="^~/news/(\d*)-(.*).aspx" 
              rewriteUrlParameter="ExcludeFromClientQueryString" 
              destinationUrl="~/news.aspx?id=$1" 
              ignoreCase="true" />

    Sascha

  • Martin Peter Hanke 5 posts 25 karma points
    Aug 23, 2010 @ 12:32
    Martin Peter Hanke
    0

    Perfect!

    thanks alot! Works like a charm!

  • fawad 6 posts 26 karma points
    Oct 28, 2010 @ 14:43
    fawad
    0

    Hello.

    i am new to umbraco. i have one used car exporter website based on umbraco.

    my url is like this "http://www.sitename.com/make=21&c=na&name=honda

    i would like to rewrite this url, but i am not getting the rewritten url in address bar. its still showing the old url.

    i have created the link like this:

    <

    li><a href='/stocksearch.aspx?make=21&c=na&name=toyota'>TOYOTA</a></li>

    currently i am writing the rule in urlrewriting.config like this:

    <

    i have turned on these two bits in web.config.

    add name="makenamerewrite" virtualUrl="^~/(.*)/(.*)/(.*).aspxwriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/stocksearch.aspx?make=$1&c=$2&name=$3" ignoreCase="true" />

    umbracoHideTopLevelNodeFromPath=true

    umbracoUseDirectoryUrls=true;

     

    i have also done the wildcard mapping in IIS.

     

    Kindly help me asap.

     

    Thanks alot

  • Anders Brännmark 226 posts 277 karma points
    Apr 20, 2011 @ 20:07
    Anders Brännmark
    0

Please Sign in or register to post replies

Write your reply to:

Draft