[英]URL Rewrite to a subdomain
我正在使用ASP.NET的重写工具来从http重定向到hpps。 我想重新路由到
https://services.net/ExitInterview/home/about
但目前它正在路由到
https://services.net/home/about
以下是我的重定向规则:
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}"
redirectType="Permanent" />
</rule>`
我可以在规则字符串中混合使用“ HTTP_HOST”文本和硬编码文本吗? 还是有另一种方法?
我不想对URL进行硬编码,因为它随本地,暂存和生产而变化。
<rule name="HTTP to HTTPS redirect" ="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/ExitInterview/{R:1}"
redirectType="Permanent" />
</rule>
试试这个
从web.config文件中的HTTP重定向到HTTPS方面,这应该可以满足您的要求:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<httpRuntime executionTimeout="180" />
</system.web>
<system.webServer>
<httpErrors errorMode="Detailed" existingResponse="PassThrough" />
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我将这个确切的片段用于实施HTTPS重定向的Web服务器,但这似乎与您拥有的内容非常接近。 您确定已经正确配置了web.config文件的结构吗? -我记得当我遗漏某些东西时遇到了问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.