Laravel 7 使用 IIS 将特定的 http 端口重定向到 https

时间:2021-04-21 20:24:57

标签: .htaccess http redirect https laravel-7

我有一个网站,有两个端口,一个是 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

0 个答案:

没有答案