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

时间:2016-05-08 10:11:47

标签: php .htaccess drupal drupal-6

我有Drupal Site。

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

我需要将我的完整网站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]

任何帮助非常感谢。

2 个答案:

答案 0 :(得分:2)

您可以使用:

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

答案 1 :(得分:0)

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

 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]

请尝试一下,如果没有做你想做的事,请告诉我。

相关问题