如何在IIS 8中配置HTTP重定向以保持入站协议不变 [英] How to configure HTTP redirection in IIS 8 to keep the inbound protocol intact

查看:621
本文介绍了如何在IIS 8中配置HTTP重定向以保持入站协议不变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小问题,我的搜索功能让我没有回答。



示例情况

我是域名example.org和www.example.org的所有者

我想将example.org重定向到www.example.org

IIS 8中已存在一个处理这两个域的网站



我做了什么?

1.在IIS 8中为名为example.org的新网站创建一个空文件夹

2.在IIS 8中创建一个主机名为example.org的新网站

3.在这个新网站上添加https绑定

4.按如下方式配置HTTP重定向:

用于将请求重定向到此目的地我设置了值www.example.org

重定向行为被配置为保持相对路径和查询完整,并包括重定向到子目录(没有任何反正)并使用永久重定向。



什么不起作用?

重定向工作完全正常,除了一个小细节:用于入站请求的协议被删除。



这意味着:

请求< a href =https://example.org> https://example.org 会重定向到 http://www.example .org



我们基本上有以下情况:

 http  - > http 
https - > http





我的实际问题

是否可以配置HTTP重定向保持入站协议?从我看来,这应该是一件非常简单和容易的事情,我不明白为什么这不起作用

 http  - > http 
https - > https





到目前为止我尝试了什么

谷歌没有帮助我找到了大量关于如何将http重定向到https的搜索结果。但那真的不是我想要的。



我试图将请求从www.example.org重定向到https://www.example.org(参见第4步) 我做了什么?)然后我与之前的相反(一切都转到https)

 http  - > https 
https - > https





我发现一个关于网址重写的类似问题 here [ ^ ]但url重写并不是我真正的意思尝试或想要。





我已经感谢你的帮助了;)





TL; DR

IIS 8,HTTP重定向,保留协议(http / https),没有有用的搜索结果(到目前为止) )

解决方案

您好b $ b您必须为IIS安装URL重写模块,然后使用以下内容:



 <  重写 >  
< system.webserver >
< ; 规则 >
< rule name = http to https 已启用 = false 停止处理 = true >
< 匹配 url = (。*) / >
< 条件 >
< add input = {HTTPS} 模式 = ^ OFF


/ > ;
< / conditions >
< action < span class =code-attribute> type = 重定向 url = https:// {HTTP_HOST} /ISOS.EHP.API/ redirecttype = 参见 / >
< / rule >
< / rules &g t;

< / system.webserver >


I have a small question where my search fu has left me without an answer.

Example situation
I'm owner of the domains "example.org" and "www.example.org"
I want to redirect "example.org" to "www.example.org"
There already exists a website in IIS 8 that handles both domains

What I did?
1. Create an empty folder for a new "website" in IIS 8 called "example.org"
2. Create a new website in IIS 8 with hostname "example.org"
3. Adding a https binding to this new website
4. Configuring the "HTTP Redirect" as follows:
For "Redirect request to this destination" I set the value "www.example.org"
The redirect behaviour is configured to keep the relative path and query intact and to include redirects to subdirecties (there aren't any anyways) and to use a permanent redirect.

What doesn't work?
The redirection works perfectly fine except a small detail: The protocol used for the inbound requests gets dropped.

That means:
Requests to https://example.org are redirected to http://www.example.org

We have basically the following scenario:

http --> http
https --> http



My actual question
Is it possible to configure the HTTP redirection to keep the inbound protocol? From my view this should be something so trivial and easy that I don't understand why this doesn't work

http --> http
https --> https



What I tried so far
Google wasn't helpfull at all I found tons of search results about how I can redirect http to https. But that really isn't what I want.

I tried to configure to redirect the requests from "www.example.org" to "https://www.example.org" (See the Step 4 of "What I did?") but then I have opposite of what I had before (everything goes to https)

http --> https
https --> https



I found a similiar question on SO concerning url rewriting here[^] but url rewriting isn't really what I try or want.


I already thank you for your assistance ;)


TL;DR
IIS 8, HTTP Redirection, keep protocol (http/https), no helpful search results (so far)

解决方案

Hi You have to install URL rewrite module for IIS and then use following:

<rewrite>
<system.webserver>
     <rules>
       <rule name="http to https" enabled="false" stopprocessing="true">
         <match url="(.*)" />
         <conditions>
           <add input="{HTTPS}" pattern="^OFF


" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/ISOS.EHP.API/" redirecttype="SeeOther" /> </rule> </rules> </system.webserver>


这篇关于如何在IIS 8中配置HTTP重定向以保持入站协议不变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆