开发者

IIS rewriting ala SO

开发者 https://www.devze.com 2023-02-01 05:17 出处:网络
Lets say that I have a site called http://sub.example.com/ I want to rewrite requests so that when a user types in:

Lets say that I have a site called

http://sub.example.com/

I want to rewrite requests so that when a user types in:

http://sub.example.com/id/company-name

It should internally be rewritten to:

http://sub.example.com/public.aspx

(I guess this is similar to the way SO question links are handled, where all questions have a unique id and a not unique title, and only the id is used to generate the page. This way an old link to a question will still work even after the title of the question has been changed)

I try to do this: In Application_BeginRequest in global.aspx I first recognizing that the requested page is a “public” page. Then I make a

HttpContext.Current.RewritePath("~/public/default.aspx", False)

In ~/public/default.aspx I then fetch the id to dynamically generate a company specific page (company logo and name for instance). This is working well on my local development environment but at the server it seems that Application_BeginRequest is not triggered. I guess this is because the requested f开发者_Python百科older does not exist?

How do I solve this problem, or are there better ways to implement this behavior?


On IIS6 I used URL Rewriter (Open Source, free). On IIS 7 (or 7.5) I successfully used the URL Rewrite module from Microsoft.

0

精彩评论

暂无评论...
验证码 换一张
取 消