网站被重定向到https但需要一些http [英] Site is redirected to https but need some with http

查看:137
本文介绍了网站被重定向到https但需要一些http的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

整个网站被重定向到https但是我需要一些页面重定向到http,这可以用web.config吗?



我需要以下页面(包。 php和hotelonly.php)重定向到http,因为我的所有其他页面都会自动重定向到https。



我试图通过以下代码实现此目的但它会不工作。



Whole site is redirected to https but I need some pages to redirected to http, is this possible with web.config?

I need following pages (packages.php and hotelonly.php) to redirect to http, as all my other pages are automatically redirected to https.

I am trying to achive this with following code but it will not work.

  <rewrite>
   <rules>
    <rule name="Canonical Host Name" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^domain\.com$" />
      </conditions>
      <action type="Redirect" url="https://www.domain.com{R:1}" redirectType="Permanent" />
    </rule>
    <rule name="Force HTTPS" stopProcessing="true">
      <match url="(.*)" />
      <conditions logicalGrouping="MatchAll">
        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
        <add input="{REQUEST_URI}" negate="true" pattern="^(packages|hotelonly)\.php$" ignoreCase="true" />
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>





我的尝试:



我已经尝试过上面的代码,但它不起作用。



What I have tried:

I have tried the code above but it will not work.

推荐答案

/ >
< / conditions >
< action 类型 = 重定向 url = https :// www.domain.com {R:1} redirectType = 永久 / >
< / rule >
< rule name = 强制HTTPS stopProcessing < span class =code-keyword> = true >
< 匹配 url = (。 *) / >
< 条件 logicalGrouping = MatchAll >
< add < span class =code-attribute> input = {HTTPS} pattern = off ignoreCase = true / >
< add 输入 = {REQUEST_URI} < span class =code-attribute> negate = true pattern = ^(packages | hotelonly)\.php
" /> </conditions> <action type="Redirect" url="https://www.domain.com{R:1}" redirectType="Permanent" /> </rule> <rule name="Force HTTPS" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll"> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> <add input="{REQUEST_URI}" negate="true" pattern="^(packages|hotelonly)\.php


ignoreCase = true < span class =code-attribute> / >
< / conditions >
< action type = 重定向 url = https:/ / {HTTP_HOST} / {R:1} appendQueryString = true redirectType = 永久 / >
< / rule >
< / rules >
< / rewrite >
" ignoreCase="true" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" /> </rule> </rules> </rewrite>





我的尝试:



我已经尝试过上面的代码,但它不起作用。



What I have tried:

I have tried the code above but it will not work.


这篇关于网站被重定向到https但需要一些http的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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