【问题标题】:How to get the "originally requested" URL when using IIRF URL Rewriting Engine使用 IIRF URL 重写引擎时如何获取“最初请求的”URL
【发布时间】:2011-04-23 04:43:03
【问题描述】:

我在 IIS 上使用 Iconic 的 IIRF URL Rewriting Engine,“花哨”的 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

这就是为什么我需要原始网址进行比较。

【问题讨论】:

    标签: iis seo url-rewriting iirf


    【解决方案1】:

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

    来自IIRF manual

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

    只需将修饰符U 添加到您希望保留其原始网址的RewriteRule。例如:

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

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

    Request.ServerVariables("HTTP_X_REWRITE_URL")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-03
      • 1970-01-01
      • 1970-01-01
      • 2015-03-11
      • 1970-01-01
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多