因此,在我的WordPress网站的htaccess文件中,我有:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
我想要输入的所有网址都转到https://example.com(https,没有www。)
目前此处运作良好:
http://example.com = https://example.com
www.example.com = https://example.com
然而,在页面上它不起作用:
http://example.com/page/ = example.com/page/
www.example.com/page/ = example.com/page/
如何将其转到https版本?
答案 0 :(得分:0)
将htaccess文件更改为以下内容,它将对您有用。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}/ [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^$ https://example.com/? [L,R=301]
</IfModule>
答案 1 :(得分:0)
您可以使用:
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]
答案 2 :(得分:0)
您可以在.htaccess
:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [NE,L,R=301]
答案 3 :(得分:0)
这似乎已经成功了......
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
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