url rewriting without having access to iis

Last post 11-15-2009 1:48 AM by RickNZ. 3 replies.

Sort Posts:

  • url rewriting without having access to iis

    11-09-2009, 10:47 AM
    • Member
      point Member
    • jschumann
    • Member since 05-08-2008, 9:00 PM
    • Posts 3

    I am trying to create a website that when a user types in a url like this http://www.something.com/option1/option2/option3 it uses rewriting to go to http://www.something.com/webpage.aspx?id=#.

     

    I have a website hiearchy in mysql. I want to be able to take what they have for option1, option2, and option3 to go through the hiearchy and get the id.  

     

    I do not have access to iis. I know it is has iis 7 and Microsoft URL Rewrite is installed. I have read some solutions about going into iis 7 and using the * to handle folder urls. I don't have access to do that.

     

    Is there a to handle what I'm looking for? I have created a httpmodule which works for .aspx extensions. I just need some way of doing this when I don't have extensions.

     

    Thanks

    Jeff

  • Re: url rewriting without having access to iis

    11-09-2009, 11:03 AM
    Answer
    • Participant
      958 point Participant
    • Brent Jenkins
    • Member since 11-07-2007, 10:43 PM
    • UK
    • Posts 177

    Hi Jeff,

    You can do this without having to access IIS by doing the following:

    1. Create Global.asax in your website

    2. In Application_BeginRequest you can add code to detect what URL has been specified and then do a rewrite to the actual URL you require to display that page, e.g.

    string targetUrl = ""; // This needs to be the actual URL you're trying to map the friendly URL to, so you'll need some code to pair the two together
    
    HttpContext.Current.RewritePath(targetUrl);


    Remember you'll probably only want to do this for .aspx files! Css, images, etc., should probably be allowed to do their "usual" thing without rewriting. 

    I found this article by Scott Guthrie to be very helpful with understanding URL rewriting: http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

    Brent Jenkins
    Director, Vale Web Design Ltd
    Web: www.valewebdesign.co.uk
    LinkedIn: http://www.linkedin.com/in/valewebdesign
  • Re: url rewriting without having access to iis

    11-09-2009, 11:16 AM
    • Member
      point Member
    • jschumann
    • Member since 05-08-2008, 9:00 PM
    • Posts 3

    Yeah, I have looked at the link alot. That works for .aspx, however I need it to work for extensionless urls. Approach 3 has a way to handle extensionless urls by putting a rewrite section within your web.config. The problem I have is that my website hiearchy may have changed by addition and removal of pages.

     

    I wonder if I could have all requests go through a single rewrite url. From there I could determine if it is extensionless and then at that point do a rewrite? 

  • Re: url rewriting without having access to iis

    11-15-2009, 1:48 AM
    • Contributor
      5,228 point Contributor
    • RickNZ
    • Member since 01-01-2009, 3:43 AM
    • Nelson, New Zealand
    • Posts 873

    If you use an HttpModule instead of Global.asax, and register the HttpModule so that it runs in Integrated mode, (preCondition="integratedMode"), then the HttpModule will run with static files as well as with .aspx files -- that should include extensionless URLs, too, provided you catch them early enough in the pipeline before IIS rejects them as 404 Not Found.


Page 1 of 1 (4 items)