[英]how to redirect https://www.example.com/aaa to https://example.com/aaa/
I use this one to force the trailing slash.我用这个来强制尾随斜杠。 But it is not working for example.com example.com or www.example.com should be redirected to https://example.com/但它不适用于 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]
```
Help me please.请帮帮我。
Could you please try following, try to put this in starting of your htaccess file.您能否尝试以下操作,尝试将其放在 htaccess 文件的开头。
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301,QSA,NC]
NOTE: This will also depend on how SSL is handled on your system, see this very informative and descriptive comment from @MrWhite Force HTTPS on my rewrite and rule .htaccess file注意:这也取决于 SSL 在您的系统上的处理方式,请参阅@MrWhite Force HTTPS 关于我的重写和规则 .htaccess 文件的非常翔实和描述性的评论
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.