简体   繁体   English

不从HTTP重定向到HTTPS

[英]not redirecting to HTTPS from HTTP

I had tried every method of redirection ie .htaccess but none of the things work for me. 我尝试了所有重定向方法,即.htaccess但是对我来说,这些都不起作用。 as right now the .htaccess file contains 现在, .htaccess文件包含

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.booksoncall.in/$1 [R=301,L]

it work fine on my computer and the http is redirecting successfully to https version, but http version is still accessable on other pc and is not redirecting to https same is happening on mobile devices. 它在我的计算机上正常工作,并且http成功重定向到https版本,但是在其他PC上仍然可以访问http版本,并且无法重定向到https,而在移动设备上也是如此。 website --- booksoncall.in 网站--- booksoncall.in

Give this a try if you want all requests to be redirected to https 如果您希望所有请求都重定向到https,请尝试一下

RewriteEngine on
RewriteCond %{SERVER_NAME} = example.com  [OR]
RewriteCond %{SERVER_NAME} = www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

This should be done in the Vhost file for port 80 这应该在端口80的Vhost文件中完成

for short version. 简短版本。 you dont need the server name. 您不需要服务器名称。

RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

If you want to redirect all http request to https why not use 如果要将所有http请求重定向到https,为什么不使用

<VirtualHost 0.0.0.0:80> 

    ServerName www.example.com:80

    Redirect permanent / https://www.example.com/

</VirtualHost>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM