繁体   English   中英

网址屏蔽使用.htaccess将http重定向到https

[英]url-masking redirect http to https using .htaccess

我已经在门户网站上创建了URL掩码(URL映射)。 相同的php代码以不同的网址运行。 我的门户网站链接是http://subdomain.domain.in (主链接),客户端URL是http://www.client-domain.com 我想使用我的.htaccess文件将客户端URL HTTP重定向到https。

编辑评论:

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^client-domain.in [NC] 
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI}/$1 [L,R=301] 
RewriteCond %{HTTP_HOST} ^mydomain.in [NC] 
RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI}/$1 [L,R=301]

您可以将以下代码用于相同的

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

它将您的网址http重定向到https。

我的问题现在解决了。 我在.htaccess中添加了此代码,并且客户端的url与HTTPS一起使用。

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} www.client-domain.com [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^my-domain.in [NC]
RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI}/$1 [L,R=301]

暂无
暂无

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

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