2017-02-03 130 views
0

我已经看到其他答案,但没有人接受,似乎有不同的答案,有些人说工作,有些人说不。htaccess重写https从www到非www

以下几乎所有我需要的重新指示https://domain.com。非SSL万维网到非万维网,强制SSL等

但是,我仍然无法得到工作的东西是https www到非www重定向。

任何帮助,将不胜感激。

# BEGIN WordPress 
 
<IfModule mod_rewrite.c> 
 
RewriteEngine On 
 
RewriteCond %{HTTP_HOST} ^www.domain.com [NC] 
 
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301] 
 
RewriteCond %{HTTPS} off 
 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 
 
RewriteBase/
 
RewriteRule ^index\.php$ - [L] 
 
RewriteCond %{REQUEST_FILENAME} !-f 
 
RewriteCond %{REQUEST_FILENAME} !-d 
 
RewriteRule . /index.php [L] 
 
</IfModule> 
 
# END WordPress

回答

1

您可以使用:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC] 
RewriteRule^https://%1%{REQUEST_URI} [NE,L,R=301] 
RewriteCond %{HTTPS} off 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301] 

RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 
# END WordPress 
+0

这仍然没有重定向https://www.domain.com/到https的非www://域名.com /,这是我缺少的部分。 –

+0

是的,它的确如此。清除缓存或尝试与其他浏览器。 – Croises

+1

这确实奏效。抱歉。标记为已接受。 –

相关问题