我有一个托管在GCP桶上的网站,我使用cloudflare作为HTTPS。如何使用.htaccess文件删除www。从所有的网页重定向到HTTPS?
基本上,我想:
http://www.example.com/ redirect to https://example.com/
https://www.example.com/ redirect to https://example.com/
and any other pages like
https://www.example.com/about.html or http://www.example.com/about.html redi
我已经将我的.htaccess文件设置为将重定向到。但是不会重定向到https。
我在site.com上设置了我的AWSroute53,还有一个别名www.example.com指向example.com。
这是我的.htaccess文件。我无论如何也想不出如何将所有内容重定向到。
RewriteBase /
RewriteEngine on
#WARNING: NEEDED FOR ONLINE VERSION - always have www in url
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http
我刚刚切换到HTTPS。我之前将重定向设置为非www+无尾部斜杠+无文件扩展名。我已将重定向更改为HTTPS。我坚持将http non-www重定向到https non-www。http www到https non-www重定向工作正常。
我得到了以下代码,主要来自这里的答案。服务器为Apache 2.4.33 (Unix)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
#example.com/page will display the contents of e