htaccess - 将单个 HTML 页面重定向到 HTTPS
htaccess - redirect single html page to https
我需要将单个html页面重定向到https。为此,我也尝试 https://stackoverflow.com/questions/16152914/redirect-single-page-http-to-https 这个。但它不起作用。
我的网址格式是http://www.example.com/api/test.html
,我需要将此测试.html页面转换为https://www.example.com/api/test.html
请提供任何帮助。
使用 PHP
if (!preg_match("/https/i", $_SERVER['SERVER_PROTOCOL'])) {
header("Location: https://" .$_SERVER["SERVER_NAME"] ."/" . $_SERVER["REQUEST_URI"]);
die();
}
它应该可以工作,
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
您可以使用:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} 's/+api/test'.html['s?] [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]
相关文章:
- 通过javascript重定向html传递php变量
- web配置http到https重定向异常
- 在Chrome扩展中使用PAC文件重定向HTTPS请求似乎失败了
- 通过端口更改自动重定向到 https
- 检查用户提供的网址是否会重定向到 https 或 http
- htaccess - 将单个 HTML 页面重定向到 HTTPS
- 将所有http请求重定向到帆js中的https
- 将网站重定向到HTTPS,重试次数有限
- 防止在服务工作者中阻止从https重定向到http
- Express 4– 将所有路由的HTTP重定向到HTTPS
- 正在加载可能重定向到HTTP的HTTPS图像url
- location.href未重定向到https://urls
- 用户登录后将所有网页重定向到HTTPS
- 重定向到安全服务器(https)
- 什么是最'犹太教'或& # 39;正确# 39;实现HTTPS重定向的方法
- 将nodejsexpress静态请求重定向到https
- 表达4.X重定向HTTP到https
- 只使用ajax进行登录https://,以避免重定向时出现警告
- JavaScript :始终重定向到 HTTPS
- Youtube重定向http到https,并使用flash播放器而不是HTML5