我有以下htaccess代码:
<IfModule mod_rewrite.c>
# enable Rewrite engine
RewriteEngine on
# redirect http to https
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
我已经完成了从http://
到https://
的重定向,但我也想重定向(出于原因),所有网址从https://www
到https
< / p>
但我不知道如何做到这一点!
答案 0 :(得分:0)
您可以使用:
RewriteEngine on
# http(s) www -> https
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R=301]
# http -> https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]