【发布时间】:2018-12-25 20:41:18
【问题描述】:
我的网站流量很大,因此性能至关重要。我正在使用 apache 和 ubuntu。
我正在尝试将所有可能的域可能性重定向到 https://example.com,包括所有子域 (https://test.example.com)。
这是我目前拥有的:
RewriteEngine On
# match any URL with www and rewrite it to https without the www
RewriteCond %{HTTP_HOST} ^(www\.)(.*) [NC]
RewriteRule (.*) https://%2%{REQUEST_URI} [L,R=301]
# match urls that are non https (without the www)
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^(www\.)(.*) [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
我觉得上面的代码正在做额外的重新路由/工作。在虚拟主机文件或 .htaccess 中是否有更直接的解决方案(以获得更快的性能)?
谢谢!
【问题讨论】:
标签: apache performance .htaccess mod-rewrite https