Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 无法将www重定向到裸版(使用Cloudflare的SSL)_.htaccess_Redirect_Ssl_Cloudflare - Fatal编程技术网

.htaccess 无法将www重定向到裸版(使用Cloudflare的SSL)

.htaccess 无法将www重定向到裸版(使用Cloudflare的SSL),.htaccess,redirect,ssl,cloudflare,.htaccess,Redirect,Ssl,Cloudflare,我使用了CloudFlare,并使用ReallySimpleSSL插件为我的站点设置了SSL,一切都很顺利,只是站点现在没有将www版本重定向到裸版,裸版是我的首选域,也是目前在网站管理员工具中使用的域 我使用了以下代码: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQU

我使用了CloudFlare,并使用ReallySimpleSSL插件为我的站点设置了SSL,一切都很顺利,只是站点现在没有将www版本重定向到裸版,裸版是我的首选域,也是目前在网站管理员工具中使用的域

我使用了以下代码:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
我真的很感激任何帮助,因为我的网站收到了相当多的流量,我不想把它搞砸

问候,,
Naser.

使用Cloudflare,更容易使用他们的规则(Cloudflare->页面规则->转发URL 301)

如果不想使用Cloudflare规则,可以使用:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"'
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
</IfModule>

重新启动发动机
重写cond%{HTTP_HOST}^www\(.+)[NC]
重写规则^https://%1%{REQUEST_URI}[NE,L,R=301]
重写cond%{HTTP:CF Visitor}'方案:“HTTP”'
重写规则^https://%{HTTP_HOST}%{REQUEST_URI}[NE,L,R=301]
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"'
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
</IfModule>