简体   繁体   English

使用URL重写模块进行IIS8和URL重定向

[英]IIS8 and URL redirect using URL Rewrite Module

I have two sites running on a Server 2012 R2 web server: 我在Server 2012 R2 Web服务器上运行两个站点:

  • firstSite, port 80 firstSite,端口80
  • secondSite, port 1234 secondSite,端口1234

Right now, users have to type in the host name, port number, and sub folder in order to view the 'Second Site' http://webServer:1234/subFolder . 现在,用户必须输入主机名,端口号和子文件夹才能查看“第二站点” http://webServer:1234/subFolder

I'm trying to simplify the URL so that all users can just type in the URL site.myDomain.com and have it (permanently) redirected to site.mydomain.com:1234/subFolder . 我正在尝试简化URL,以便所有用户都可以输入URL site.myDomain.com并将其(永久)重定向到site.mydomain.com:1234/subFolder

I've tried applying the following rule on my secondSite: 我尝试在我的secondSite上应用以下规则:

<rewrite>
    <rules>
        <rule name="Redirect" stopProcessing="true">
            <match url=".*" />
                <action type="Redirect" url="http://site.mydomain.com:1234/subFolder"  />
        </rule>
    </rules>
</rewrite>

But doesn't seem to do anything. 但是似乎什么也没做。

A CNAME record has already been configured in DNS for site.myDomain.com to resolve to http://webServer . DNS中已经为site.myDomain.com配置了CNAME记录,以解析为http://webServer

I just need help with getting the redirection to 'secondSite' at port 1234. 我只需要获得有关重定向到端口1234的“ secondSite”的帮助。

I assume the first site is hosted on IIS and the rule is running within the context of the first site. 我假设第一个站点托管在IIS上,并且规则在第一个站点的上下文中运行。 If so, it should work...to validate your setup, I'd start with this article and the augment with your use case: 如果是这样,它应该可以工作……以验证您的设置,我将从本文开始,然后从您的用例开始:

http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

<configuration>
   <system.webServer>
      <httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
         <add wildcard="/some/folder/path/" destination="/new/folder/" />
      </httpRedirect>
   </system.webServer>
</configuration>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM