2010-10-09 56 views
3

我使用IIS上的標誌性的IIRF URL Rewriting Engine和「花哨」的網址是這樣的,以獲得「最初請求」網址:如何使用IIRF URL重寫引擎

http://some-website.com/some-function/418/some-keyword-rich-filename.html 

這個例子URL對應於:

http://some-website.com/some-function.asp?SOME-ID=418 

現在在some-function.asp文件中,我需要知道瀏覽器請求的頁面。我瀏覽了所有IIS變量,但無法在其中找到值/some-function/418/some-keyword-rich-filename.html

作爲一個便箋,我需要這些信息發送301重定向到瀏覽器。例如。如果瀏覽器請求:

http://some-website.com/some-function/418/index.html 

我首先需要將瀏覽器發送至:

http://some-website.com/some-function/418/some-keyword-rich-filename.html 

這就是爲什麼我需要原始URL進行比較。

回答

6

對於IIRF,這稱爲unmangling,可以通過使用修飾符U來實現。

IIRF manual:在服務器 可變HTTP_X_REWRITE_URL

U =商店原始地址

修飾語U只需添加到RewriteRule爲您想保留原來的URL。例如:

RewriteRule ^/some-function/(\d+)/(.*)$ /some-function.asp?SOME-ID=$1 [I,U,L] 

然後,在你some-function.asp頁面的代碼,你可以訪問原始URL是這樣的(傳統的ASP):

Request.ServerVariables("HTTP_X_REWRITE_URL")