【发布时间】:2018-10-01 19:47:18
【问题描述】:
当前代码
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.test.com$ [OR]
RewriteCond %{HTTP_HOST} ^test.com$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
我需要将非 www 流量重定向到 HTTPS www,但需要保留直接访问的 www 流量而不强制执行 HTTPS。
所以我尝试了这个
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^test\.com$ [OR]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://test.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.test.com$ [OR]
RewriteCond %{HTTP_HOST} ^test.com$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
但我收到“太多重定向”,不知道为什么。 index.php 来自 laravel 安装。
【问题讨论】:
标签: laravel apache .htaccess url-rewriting