【发布时间】:2020-07-19 15:15:39
【问题描述】:
我正在尝试重定向 url 变体,以便如下所示: http://www.example.com/index.php
简单地重定向到:https://example.com (即 http 到 https;www 到非 www;index.php 到域的根目录)
# Canonical HTTPS/non-WWW
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule (.*) https://example/$1 [L,R=301]
# direct /index.php to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ https://example.com/ [R=301,L]
</IfModule>
问题: 有没有更优雅的解决方案将两者结合起来?
【问题讨论】: