AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 606228
Accepted
bgmCoder
bgmCoder
Asked: 2014-06-19 11:15:22 +0800 CST2014-06-19 11:15:22 +0800 CST 2014-06-19 11:15:22 +0800 CST

URL-重写到一个站点但不是另一个

  • 772

我们有自己的域和几个子域。其中一个站点只需要通过 SSL 访问,但人们可以输入 http 并仍然到达那里。URL-Rewrite 将 http 强制转换为 https。

所以我的两个子域是: sub1.domain.org和sub2.domain.org。

因此,如果我输入

http://sub1.domain.org/page_on_domain1

它被重写为

https://sub1.domain.org/page_on_domain1

-哪个是对的。但是如果我这样做(这是不可能的 -page_on_domain1不存在于sub2.domain.org:

https://sub2.domain.org/page_on_domain1

我的 url-rewrite 规则似乎工作正常,但我希望最后一个地址给我一个错误页面,因为该页面在该子域上不存在。

我正在 Windows 7 x64 Pro 上的 Firefox 中对此进行测试。

我的 url-rewrite 规则如下(我是通过 IIS7 GUI 来做的):

Requested URL:  Matches the Pattern:  (*)  Using Regular Expressions (ignore case)
Conditions:  Match All:  Input:  {HTTPS}  Matches the Pattern:  ^Off$
Redirect URL:  https://sub1.domain.org/{REQUEST_URI}

现在,我尝试将请求的 URL 模式更改为:.*sub1.domain.org/.*但 IIS7 中的正则表达式测试器说它不匹配https://sub1.domain.org - 我不明白这一点。

如何保持 sub1.domain.org 的 http 到 https 的重写,但对 sub2.domain.org 没有任何影响?

iis-7
  • 1 1 个回答
  • 646 Views

1 个回答

  • Voted
  1. Best Answer
    bgmCoder
    2015-02-01T17:44:31+08:002015-02-01T17:44:31+08:00

    在我想通过 访问并重写到 的特定站点的 web.config 中https,http我http设置了这个:

    <rewrite>
      <rules>
        <rule name="Redirect to HTTPS" 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>
    
    • 0

相关问题

  • 为什么我的站点在配置为直通身份验证时使用 IUSR 帐户?

  • 在 SQL Server 2008 上为 ASP.NET 应用程序设置登录名

  • 使用 Web.config 阻止对子目录的访问

  • IIS 7 中的 URL 重写

  • 无法连接到我的 FTP 服务器,为什么?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve