[英]Redirect not working for Pages and Posts URLs from http to https in Wordpress .htaccess file
我正在尝试从http重定向到我的网站的https。 我使用的代码仅适用于主页,并且可以正确重定向。 例如,它可以正确地从http重定向到https
但是,可以在http和https上访问我在wordpress网站中创建的页面,例如,可以在以下两个URL上访问该页面
http://www.example.com/any-page-url和https://www.example/any-page-url
但是我希望所有的http页面都重定向到各自的https页面。 我使用的htaccess文件是
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
您是否尝试将代码放在htacces文件的顶部。
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*)https:// % {HTTP_HOST}%{REQUEST_URI}
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
如果这不起作用,请尝试使用以下代码代替您的https重定向代码
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.