[英]How to correctly redirect all http requests to https
I have a functional URL shortening site. 我有一个功能性URL缩短网站。 Recently I added SSL to the website and configured the
.htaccess
for proper redirecting. 最近我在网站上添加了SSL并配置了
.htaccess
以进行正确的重定向。 The issue is that all of the http://
requests, redirect back to the homepage https://websi.te
问题是所有的
http://
请求都会重定向回主页https://websi.te
Currently, I've tried setting up redirecting as follows: 目前,我已尝试设置重定向如下:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
An example of what's going wrong: 出了什么问题的一个例子:
User types http://websi.te/keyword
or websi.te/keyword
and they are redirected to https://websi.te
instead of https://websi.te/keyword
用户输入
http://websi.te/keyword
或websi.te/keyword
,它们被重定向到https://websi.te
而不是https://websi.te/keyword
Change your rewrite to this: 将您的重写更改为:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]
$1 is first group match ^(.*)$, it's your request. $ 1是第一组匹配^(。*)$,这是你的要求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.