简体   繁体   English

除了 Drupal 站点中的 2 个页面之外,如何将整个站点从 HTTP 重定向到 HTTPS?

[英]how to redirect complete site from HTTP To HTTPS except for 2 pages in Drupal Site?

I have Drupal Site.我有 Drupal 站点。

I have checked all the below links, but either they don't redirect or I gets an error- Site has too many redirects我已经检查了以下所有链接,但它们要么没有重定向,要么出现错误 - 站点重定向过多

I need to redirect my complete site HTTP to HTTPS except for two pages:-我需要将我的完整站点 HTTP 重定向到 HTTPS,但两个页面除外:-

  • Home - www.hello.com首页 - www.hello.com
  • Products - www.hello.com/products产品 - www.hello.com/products

The below code-snippet redirects complete site to HTTPS with no issue but I need to escape the Home & products page & for that I have tried about with more than 10-15 combinations.下面的代码片段将整个站点重定向到 HTTPS 没有问题,但我需要转义主页和产品页面,为此我尝试了超过 10-15 种组合。

   RewriteCond %{HTTPS} off [OR]
   RewriteCond %{HTTP_HOST} ^www.hello\.com*
   RewriteRule ^(.*)$ https://hello.com/$1 [L,R=301]

Any Help Highly appreciated.任何帮助 高度赞赏。

You can use:您可以使用:

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.hello\.com
RewriteCond %{REQUEST_URI} !^/products/?$ [NC]
RewriteRule ^(.+)$ https://hello.com/$1 [L,R=301]

Ok let's try with you , this is your code :好的,让我们和你一起试试,这是你的代码:

 RewriteCond %{HTTPS} off [OR]
 RewriteCond %{HTTP_HOST} ^www.hello\.com*
 RewriteRule ^(.*)$ https://hello.com/$1 [L,R=301]

change it to this :将其更改为:

RewriteEngine on
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www.hello\.com*
RewriteCond %{SCRIPT_FILENAME} !products [NC]
RewriteRule ^(.+)$ https://hello.com/$1 [L,R=301]

Please try it and let me know if not doing what you want.请尝试一下,如果没有做你想做的,请告诉我。

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

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