将所有流量重定向到https和www - 目前仅适用于主域,而不是子页面

时间:2018-03-21 16:08:50

标签: wordpress apache .htaccess redirect mod-rewrite

我需要将所有流量重定向到WordPress网站上的https和www。我已经浏览了几十个stackoverflow帖子,觉得我终于找到了答案:htaccess redirect to https://www

我在我的htaccess文件中使用下面的代码,它有点工作。根域inspiresoftware.com重定向到https://www.inspiresoftware.com。但是如果我直接去一个子页面。 inspiresoftware.com/library,它重定向到www版本,但不是https版本。我需要编辑什么才能同时执行这两项操作?谢谢!

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /q
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

0 个答案:

没有答案