2017-08-15 49 views
-1

我想要随时访问WordPress的管理与HTTPS。我使用这个(从我读的博客复制和粘贴)htaccess在WordPress的:为什么HTTP到HTTPS似乎并不工作

# Redirection to HTTPS 
    RewriteCond %{SERVER_PORT} ^80$ [OR] 
    RewriteCond %{HTTPS} =off 
    RewriteRule ^(.*)$ https://example.com/$1 [R=301,L] 

    # Redirection from www to non-www HTTPS 
    RewriteCond %{HTTP_HOST} ^www\.example\.com [NC] 
    RewriteRule ^(.*)$ https://example.com/$1 [R=301,L] 

这是行不通的。我总是必须手动修改网址。

回答

1

尝试在第一行添加“RewriteEngine on”,如果条件“%{SERVER_PORT} 80”应该足够好,我还会删除条件“%{HTTPS} = off”。

RewriteEngine on 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://example.com/$1 [R,L] 

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