Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
Wordpress .htaccess将http/https www重定向到https非www_Wordpress_.htaccess_Redirect_Https - Fatal编程技术网

Wordpress .htaccess将http/https www重定向到https非www

Wordpress .htaccess将http/https www重定向到https非www,wordpress,.htaccess,redirect,https,Wordpress,.htaccess,Redirect,Https,我正在谷歌云上的wordpress网站上疯狂地尝试重定向所有内容,例如。到 我目前正在使用以下内容,这在示例中是最容易转移注意力的: RewriteEngine on RewriteCond %{HTTPS} !=on [NC] RewriteCond %{REQUEST_URI} !wp-content\/cache\/(all|wpfc-mobile-cache) RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] RewriteCon

我正在谷歌云上的wordpress网站上疯狂地尝试重定向所有内容,例如。到

我目前正在使用以下内容,这在示例中是最容易转移注意力的:

RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteCond %{REQUEST_URI} !wp-content\/cache\/(all|wpfc-mobile-cache)
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

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

RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
它指导以下链接:;到

但它不会使用重新定向链接

任何帮助都将不胜感激

您可以使用:

RewriteEngine on
# www -> https without www
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R=301]
# http -> https
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !wp-content/cache/(all|wpfc-mobile-cache)
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]

试试看,它应该也能用。。这就是将所有“http”请求重定向到“https”所需的全部内容,但请注意,您仍然需要在站点上安装有效的SSL证书

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]