apache - 重定向到 HTTPS,除了一系列 URL
问题描述
我需要在一系列网址上推迟 https ......
现在我得到了这个: https ://sub.domain.com/release/download/ {id}
我需要将所有 /release/download/{id} url 重定向到 http
我从这里尝试了几种解决方案: Mod_rewrite http->https 重定向除了一个 URL
但没有一个工作。
我在我的 apache conf 中得到了这个:
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
解决方案
您可以使用以下 RewriteRule
RewriteEngine On
#redirect http to https except "/release/download/*
RewriteCond %{REQUEST_URI} !^/release/download/.*
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
推荐阅读
- heroku - 该站点在 localhost 中运行良好,但在 heroku 上部署时出现错误。error-TypeError: OAuth2Strategy 需要一个 clientID 选项
- python-3.x - 总结多个excel行
- javascript - 如何在 stackblitz 中安装丢失的软件包?
- jquery - 如何使用 Thymeleaf 和 JQuery 绑定动态子列表?
- postgresql - Postgresql - 根据条件选择列
- arrays - 无法从字符串数组中删除空格
- database - 在springboot中,我可以连接两个数据库吗?如果一个数据库出现异常,我可以动态连接到另一个数据库
- javascript - 在 React Native 中的循环内更新状态变量
- python - 如何删除 BeautifulSoup 中的父元素?
- security - 如何列出所有可公开访问的 GCP 资源?