使用IIRF URL重写引擎时如何获取"最初请求的"URL

Sal*_*n A 3 iis seo url-rewriting iirf

我在IIS上使用Iconic的IIRF URL重写引擎,"花式"URL就是这样的:

http://some-website.com/some-function/418/some-keyword-rich-filename.html
Run Code Online (Sandbox Code Playgroud)

此示例网址对应于:

http://some-website.com/some-function.asp?SOME-ID=418
Run Code Online (Sandbox Code Playgroud)

现在在some-function.asp文件中我需要知道浏览器请求的页面.我浏览了所有IIS变量,但无法在其中找到/some-function/418/some-keyword-rich-filename.html任何值.

作为旁注,我需要此信息才能将301重定向发送到浏览器.例如,如果浏览器请求:

http://some-website.com/some-function/418/index.html
Run Code Online (Sandbox Code Playgroud)

我首先需要将浏览器发送到:

http://some-website.com/some-function/418/some-keyword-rich-filename.html
Run Code Online (Sandbox Code Playgroud)

这就是我需要原始网址进行比较的原因.

mar*_*pet 6

对于IIRF,这称为unmangling,可以通过使用修饰符来实现U.

IIRF手册:

U =将原始URL存储在服务器变量HTTP_X_REWRITE_URL中

只需将修改器添加URewriteRule您要保留原始URL的位置即可.例如:

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

然后,在您的页面代码中some-function.asp,您可以像这样访问原始URL(经典ASP):

Request.ServerVariables("HTTP_X_REWRITE_URL")
Run Code Online (Sandbox Code Playgroud)