【问题标题】:Tricky set of redirections needed for URL RewriteURL 重写所需的一组棘手的重定向
【发布时间】:2013-02-01 22:18:27
【问题描述】:

如果我有一个网站,比如我的http://www.website.com,将流量重定向到default.aspx 页面但网址中没有显示的最佳方式是什么?

因此,如果用户转到http://mywebsite.com,他们会被重定向到http://mywebsite.com/default.aspx?lid=1234,但会显示为:

http://mywebsite.com?lid=1234

当我的网站上线时(显然该网站不是http://mywebsite.com,但主网址不相关)我希望能够给他们上面的网址。

目前有点棘手,当我们给他们网址时,它没有参数盖子,但现在系统需要它。

我通过将index.html 设置为更高的默认页面并使用代码http-equiv="refresh" content="0;URL=default.aspx?lid=1234"http://mywebsite.com 更改为http://mywebsite.com/default.aspx?lid1234

成功了。

如果我随后应用标准重写规则来删除 default.aspx,如下所示:http://kitsula.com/Article/URL-Rewriter-Remove-default.aspx-from-the-URL

它几乎可以工作。重定向到http://mywebsite.com/?lid=1234

我怎样才能摆脱.com之后的/

【问题讨论】:

    标签: url-rewriting


    【解决方案1】:

    当一次重写应该可以解决问题时,您似乎正在执行 2 次重定向。

    <rule name="test" stopProcessing="true">
        <match url="^/?$" />
        <action type="Rewrite" url="default.aspx?lid=1234" />
    </rule>
    

    如果用户访问http://www.website.comhttp://www.website.com/,则url 将被重写为http://mywebsite.com/default.aspx?lid=1234。 (但在用户的浏览器中,显示的 url 会保持不变)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-07
      • 1970-01-01
      • 2014-05-12
      • 1970-01-01
      • 1970-01-01
      • 2020-09-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多