简体   繁体   English

如何将 https://www.example.com/aaa 重定向到 https://example.com/aaa/

[英]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.

相关问题 如何将https://example.com/重定向到https://www.example.com/ - How to Redirect https://example.com/ to https://www.example.com/ htaccess重定向https:// www。 (https://www.example.com)到非www(https://example.com) - htaccess redirect https://www. (https://www.example.com) to non www (https://example.com) 如何将 http://www.example.com 重定向到 https://example.Z4D236D9A2D102C5ZFE6AD1Cware - How to redirect http://www.example.com to https://example.com with middleware Apache2 使用虚拟主机将 https://example.com 重定向到 https://www.example.com - Apache2 redirect https://example.com to https://www.example.com with vhosts http://example.com不会重定向到https://www.example.com - http://example.com would not redirect to https://www.example.com 解析 http://www.example.com 以通过 htaccess 永久重定向到 https://example.com - Resolving http://www.example.com to permanently redirect to https://example.com via htaccess 全部重定向到 https://www.example.com - Redirect all to https://www.example.com 将* .example.com和example.com重定向到HTTPS的www.example.com时出现问题 - Problem with redirecting *.example.com & example.com to www.example.com for HTTPS 如何使 htaccess 强制 https 用于 www.example.com 和 example.com 但没有其他子域 - how to make htaccess force https for www.example.com and example.com but no other subdomains 强制从 https://example.com 重定向到 https://www.example.com - force redirection from https://example.com to https://www.example.com
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM