.htaccess - Laravel 7 使用 IIS 将特定的 http 端口重定向到 https
问题描述
我有一个网站,有两个端口,一个是 http,另一个是 https,所以当用户用 https 的端口编写 url 时我想要的是这样的:example.com:9090 我需要将他重定向到https:/ /example.com:9090。
我试过这个:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteCond %{HTTP_HOST} example\.com:9090 [NC]
RewriteCond %{SERVER_PORT} 9090
RewriteRule ^(.*)$ https://example.com:9090/$1 [R,L]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
但是当我清除 Opcache 时出现以下错误:
In RedirectMiddleware.php line 159: Will not follow more than 5 redirects
解决方案
推荐阅读
- c# - 如何在array.orderby C#上获取随机顺序
- reactjs - 为什么我在 TypeScript 中使用 React Hook 时遇到“......既不是 React 函数组件也不是自定义 React Hook 函数”
- javascript - 为什么在 nodejs 中随处使用 Asynchornus 函数是最佳实践
- python - 在 pandas 中,将散点图添加到折线图
- java - 如何在java中以不同语言(西班牙语)从sql日期打印月份?
- ios - Flutter 应用程序 - 错误,Xcode **构建失败**
- mysql - 使用当前时间戳重命名数据库的 bash 脚本
- c# - 为什么 Visual Studio (2019) 在 LogCritical 上中断
- sql - Derby 数据库在返回值时附加空间
- windows - [已解决]服务恢复“运行程序”不起作用