Apache设置301跳转重定向
1.设置不带www跳转到www
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.abc.com$ [NC]
RewriteRule ^(.*)$ http://www.abc.com/$1 [R=301,L]
</IfModule>
2.设置HTTP跳转到HTTPS
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{HTTP:From-Https} !^on$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?abc.com$ [NC]
RewriteRule ^(.*)$ https://abc.com/$1 [R=301,L]
ErrorDocument 404 /404.php
ErrorDocument 403 /404.php
</IfModule>