首页 > 解决方案 > 重定向目标 URL 在域后缺少斜杠

问题描述

我正在尝试将所有流量重定向到 HTTPS 和 WWW。

在我的 .htaccess 中使用它:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

但是转到我的域会example.com/blog重定向到https://www.example.comblog. 这在子目录之前的域之后没有斜杠。

有什么建议么?

标签: .htaccessurlredirect

解决方案


推荐阅读