【发布时间】:2016-05-31 03:03:05
【问题描述】:
看起来有点简单的问题,但我做错了,所以我想请你帮忙:
我有一些在 MODx Evo 上制作的小网站。它放在 CloudFlare 后面(免费关税,使用非常基本的功能),主要是为了他们的免费 https。现在我尝试只设置一个地址作为基础地址:
我确实使用默认的 MODx Evo .htaccess 来提供漂亮的 URL 和一些基本的 PHP 设置,如下所示:
AddDefaultCharset utf-8
RewriteEngine On
RewriteBase /
# Fix Apache internal dummy connections from breaking [(site_url)] cache
RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
RewriteRule .* - [F,L]
# Exclude /assets and /manager directories and images from rewrite rules
RewriteRule ^(manager|assets|js|css|images|img)/.*$ - [L]
RewriteRule \.(jpg|jpeg|png|gif|ico)$ - [L]
# For Friendly URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
除了从 www 重定向到非 www 域的部分之外,这是所有内容,它是股票设置。
现在我需要做另外两个重定向条件:
- http -> https
- www -> 非www
这就是我卡住的地方。我可以轻松地将非 www 重定向到 www,但是当我添加 http/https 部分时,我得到了 301 循环。
该网站本身在 Apache 上(Cloudflare 添加了他们的特殊 Nginx 版本)。
请告知我应该在上面显示的 .htaccess 中添加什么,以便将上面显示的 all 3 个域变体很好地重定向到 https://example.org一个?
【问题讨论】:
标签: .htaccess cloudflare