简体   繁体   English

重定向到https://www.example.com

[英]Redirect to https://www.example.com

Currently I'm using http://example.com but I want redirect all to http s :// www .example.com 目前我正在使用http://example.com,但我希望将所有内容重定向到http s :// www .example.com

I read several topics here and tried quite a few solutions to this but nothing worked for me. 我在这里阅读了几个主题并尝试了很多解决方案,但对我没有任何帮助。

My last try was this: 我的最后一次尝试是:

RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

When I'm using this code I can see this: enter image description here 当我使用此代码时,我可以看到: 输入图像描述

But it gives me this message also: 但它也给了我这个信息:

The page isn't redirecting properly. 页面未正确重定向。 Firefox has detected that the server is redirecting the request for this address in a way that will never complete. Firefox检测到服务器正在以永远不会完成的方式重定向此地址的请求。

Can you help me with this? 你能帮帮我吗?

Replace example with your domain and try 用您的域替换示例并尝试

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^example\.com [NC] 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

Looks to me that you're also trying to force www. 在我看来你也试图强迫www。 You can do both by using this in your .htaccess : 你可以在你的.htaccess使用它来做到这.htaccess

RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

Place this rule to the top of your .htaccess file and make sure you clear your cache before you test it. 将此规则放在.htaccess文件的顶部,并确保测试之前清除缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将www.example.com和https://www.example.com重定向到https://example.com - Redirect www.example.com and https://www.example.com into https://example.com 将https://example.com重定向到https://www.example.com - Redirect https://example.com to https://www.example.com 将https://www.example.com重定向到https://example.com - Redirect https://www.example.com to https://example.com htaccess重定向https:// www。 (https://www.example.com)到非www(https://example.com) - htaccess redirect https://www. (https://www.example.com) to non www (https://example.com) 使用htaccess将http://www.example.com/重定向到https://www.example.com/ - redirect http://www.example.com/ to https://www.example.com/ with htaccess http://www.www.example.com重定向到https://www.example.com - http://www.www.example.com redirect to https://www.example.com htaccess将https://www.example.net重定向到https://www.example.com/members/ - htaccess redirect https://www.example.net to https://www.example.com/members/ 将https://example.com/重定向到https://www.example.com/而不更改httpd.conf - Redirect https://example.com/ to https://www.example.com/ without changing httpd.conf how to redirect https://www.example.com to https://example.com with .htaccess? - how to redirect https://www.example.com to https://example.com with .htaccess? 如何将https://www.example.com重定向到https://example.com - How to redirect https://www.example.com to https://example.com
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM