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 https://www. 到https://重定向不起作用_.htaccess_Redirect - Fatal编程技术网

.htaccess https://www. 到https://重定向不起作用

.htaccess https://www. 到https://重定向不起作用,.htaccess,redirect,.htaccess,Redirect,我需要重定向到https:// RewriteEngine On RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] 我已经尝试了在网上找到的所有可能的代码片段,以通过.htaccess实现这一点 最好的似乎是: RewriteEngine On RewriteCond %{HTTPS} off [OR] RewriteCond

我需要重定向到https://

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
我已经尝试了在网上找到的所有可能的代码片段,以通过.htaccess实现这一点

最好的似乎是:

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
但这对我不起作用

我所做的一切都没有任何效果。如果我打字,那就是我留下来的地方


我怎样才能做到这一点

这就是我正在使用的,它可以很好地重定向。至https://

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

尝试清除浏览器缓存。;-)来吧starkeen