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


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

我有Drupal网站。

我已经检查了以下所有链接,但要么他们没有重定向,要么我得到了一个错误-网站有太多的重定向

  • https://www.drupal.org/https-information
  • 将https提供的所有数据重定向到http
  • https://drupal.stackexchange.com/questions/24072/how-to-simply-make-the-whole-site-https
  • http到https的apache重定向
  • 如何从HTTPS重定向到HTTP
  • https://ilovedrupal.com/blog/redirect-http-https-apache-configuration-permanent-redirect-http-https-pages

我需要将我的完整网站HTTP重定向到HTTPS,除了两个页面:-

  • 主页-www.hello.com
  • 产品-www.hello.com/Products

下面的代码片段将整个网站重定向到HTTPS,没有任何问题,但我需要逃离Home&产品页面&为此,我尝试了超过10-15种组合。

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

任何帮助非常感谢。

您可以使用:

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

好吧,让我们试一下,这是你的代码:

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

更改为:

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]

请尝试一下,如果你不想做什么就告诉我。