url-masking 使用 .htaccess 将 http 重定向到 https

url-masking redirect http to https using .htaccess

我已经在我的门户网站上创建了 url-masking(url-mapping)。 相同的 php 代码是 运行 不同的 url。 我的传送门 link 是 http://subdomain.domain.in (main-link) and client url is http://www.client-domain.com。 我想使用我的 .htaccess 文件将客户端 URL HTTP 重定向到 https。

根据评论编辑:

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

you can use below code for the same

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

它会将您的 url http 重定向到 https。

我的问题现在已经解决了。 我在 .htaccess 中添加了这段代码,客户端的 url 使用 HTTPS。

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