通过端口更改自动重定向到 https
Automatic redirection to https with port change
与这个问题类似,我也可以如何更改端口?
if (window.location.href.indexOf('http://')==0)
window.location=window.location.href.replace('http://','https://');
例如,我想将http://localhost:8080/test/
更改为https://localhost:8443/test/
,但现在仅将其更改为https://localhost:8080/test/
有没有办法在不硬编码的情况下更改它?目前我可以像这样硬编码它window.location = "https:localhost:8443/test/"
,但是我必须为测试中的每个唯一页面执行此操作,这可能会很麻烦。
相反,有没有办法自动更改端口?
你可以重建 href:
if (window.location.href.indexOf('http://')==0)
window.location = 'https://'+window.location.hostname+':8443'+window.location.pathname+window.location.search;
相关文章:
- 通过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