.htaccess http到https将所有页面重定向到主页

时间:2016-11-04 07:25:08

标签: .htaccess https http-redirect

我刚购买了我的网站SSL许可证,我用Google搜索并尝试将一些不同的代码添加到htaccess。

我使用的第一组代码

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

我使用的第二组代码

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

REF:https://wiki.apache.org/httpd/RewriteHTTPToHTTPS

但是,网站会将没有https的所有内页重定向到https主页。

EG。 http://example.com/tag1/tag2https://example.com

但我需要将其从http://example.com/tag1/tag2重定向到https://example.com/tag1/tag2

我的代码有问题吗?还是服务器配置相关?

0 个答案:

没有答案