rewrite /mycategory/

Last post 07-23-2007 8:59 AM by sujitm. 2 replies.

Sort Posts:

  • rewrite /mycategory/

    07-22-2007, 9:40 PM
    • Loading...
    • mickyjtwin
    • Joined on 12-29-2005, 9:37 PM
    • Geelong VIC
    • Posts 171

    How would I change my httpmodule or IIS to handle an entry whereby I type:

    /mycategory/
    or
    /mycategory/2007/05/05/

    normally it will treat this as a directory, and look for:
    /mycategory/default.aspx
    or
    /mycategory/2007/05/05/default.aspx

    Obvsiously it is all dynamic, so this woudln't work.
    If I add to IIS .*, then it will process EVERYTHING, which I do not want.

    Thanks,
    Mick
     

  • Re: rewrite /mycategory/

    07-23-2007, 8:44 AM
    Answer
    • Loading...
    • gearbox
    • Joined on 07-11-2007, 7:37 PM
    • Posts 8

    You need a mod_rewrite like url rewriting tool such as IIS Mod-Rewrite, IIS Rewrite, or IIRF. I strongly recommend IIS Mod-Rewrite, but IIRF is an acceptable free solution.

    You can convert an incoming url from

    /mycategory/2007/05/05

    to

    /default.aspx?cat=mycategory&year=2007&month=05&day=05

    by using the following rewrite configuration:

    RewriteEngine On
    RewriteRule ^/([^/]+)/?([0-9]*)/?([0-9]*)/?([0-9]*)/?  /default.aspx?cat=$1&year=$2&month=$3&day=$4 [L,QSA]

    Hope this helps

  • Re: rewrite /mycategory/

    07-23-2007, 8:59 AM
    Answer
    • Loading...
    • sujitm
    • Joined on 05-23-2007, 5:01 AM
    • Pune
    • Posts 504

    You can use a HttpModule to intercept all the requests coming in for a specific directory in your case "mycategory/2007/05/05" and change the URL on the fly so that it points to the page which will process the request.

    - Sujit

    Dont forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
Page 1 of 1 (3 items)
Microsoft Communities
Page view counter