【问题标题】:How to skip HTTPS redirection, only if the url contains a substring?仅当 url 包含子字符串时,如何跳过 HTTPS 重定向?
【发布时间】:2020-04-28 22:44:45
【问题描述】:

在我的 Apache http.conf 文件中,我有以下重定向设置,这意味着如果我使用我的服务器的域名访问端点,它将提供其 HTTPS 等效项,而不是 HTTP。但是,有一个特定的 URL,我不希望该地址出现。我现在是这样设置的:

<VirtualHost *:80>
  ServerAdmin me@mydomain.com
  DocumentRoot "/srv/httpd"
  ServerName example.com
  ServerAlias example.com
  RewriteEngine On
  RewriteCond %{SERVER_NAME} =example.com
  RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

那么我需要添加什么,以便如果我要访问 http://example.com/insecure/(以及该文件夹中的任何内容),它不会将我重定向到任何地方,但是如果我正在访问其他任何内容,它会重定向到 HTTPS在我的域上?只是第二个 RewriteCond?我不确定语法

【问题讨论】:

    标签: apache redirect https


    【解决方案1】:

    我添加了RewriteCond %{REQUEST_URI} !/insecure/ 的第二个 RewriteCond,似乎已经完成了这项工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-04
      • 2014-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-18
      • 2012-03-07
      相关资源
      最近更新 更多