[英]How to Redirect https://example.com/ to https://www.example.com/
[英]how to redirect https://www.example.com/aaa to https://example.com/aaa/
我用这个来强制尾随斜杠。 但它不适用于 example.com example.com 或www.example.com应重定向到https://example.com/
```
RewriteEngine On
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
```
请帮帮我。
您能否尝试以下操作,尝试将其放在 htaccess 文件的开头。
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301,QSA,NC]
注意:这也取决于 SSL 在您的系统上的处理方式,请参阅@MrWhite Force HTTPS 关于我的重写和规则 .htaccess 文件的非常翔实和描述性的评论
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.