apache非www重定向到www和https的代码
apache非www重定向到www和https的代码
需求就是,非www访问的自动重定向到www访问,
并且把http访问重定向到https,代码如下
RewriteEngine On
RewriteCond %{HTTP_HOST} ^youdomain.com$ [NC]
RewriteRule (.*) http://www.youdomain.com/$1 [R=301,L]
###重定向到www访问
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
#重定向到https