具有两个域的IIS重写模块规范URL
我有一个Web服务器,我有两个域名具有两个域的IIS重写模块规范URL,url,redirect,iis,url-rewriting,windows-server-2012,Url,Redirect,Iis,Url Rewriting,Windows Server 2012,我有一个Web服务器,我有两个域名http://example.mx和http://example.com.mx两者都指向同一个Web服务器和根文件夹,我可以将我的网站与这两个域一起使用,目前我也可以使用www.,但这是我要删除的内容,我做到了,我得到了这个web.config文件 <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <
http://example.mx
和http://example.com.mx
两者都指向同一个Web服务器和根文件夹,我可以将我的网站与这两个域一起使用,目前我也可以使用www.
,但这是我要删除的内容,我做到了,我得到了这个web.config文件
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="CGI-exe" />
<add name="CGI-exe" path="*.exe" verb="*" modules="CgiModule" resourceType="File" requireAccess="Script" allowPathInfo="true" />
</handlers>
<rewrite>
<rules>
<rule name="CanonicalHostNameRule2" enabled="false">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example\.com\.mx$" negate="true" />
</conditions>
<action type="Redirect" url="http://example.com.mx/{R:1}" />
</rule>
<rule name="CanonicalHostNameRule1" enabled="false">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example\.mx$" negate="true" />
</conditions>
<action type="Redirect" url="http://example.mx/{R:1}" />
</rule>
<rule name="http a https" enabled="false" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
但问题是我去http://example.mx
它将我发送到http://example.com.mx
假设它的工作原理如下:
如果我转到http://www.example.mx
重定向到http://example.mx
如果我转到http://www.example.com.mx
重定向到http://example.com.mx
但是现在如果我去
http://www.example.mx
它重定向到http://example.com.mx
我不想这样,我需要在模式中改变什么 您应该使用以下规则:
<rule name="CanonicalHostNameRule2">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.example\.com\.mx$"/>
</conditions>
<action type="Redirect" url="http://example.com.mx/{R:1}" />
</rule>
<rule name="CanonicalHostNameRule1">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.example\.mx$" />
</conditions>
<action type="Redirect" url="http://example.mx/{R:1}" />
</rule>