【问题标题】:Rewrite all http traffic to https with a couple exceptions将所有 http 流量重写为 https,但有几个例外
【发布时间】:2014-03-11 05:19:12
【问题描述】:

我需要将所有页面和资产重写为 https,几个特定页面除外。这是我当前的 htaccess 代码,它适用于广泛的 https 重写。我只需要弄清楚如何为此添加特定于页面的异常。

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

我要排除的页面如下:

  • cron.php
  • mailer_confirmjob.php
  • mailer_followup.php
  • cron_duplicate_check.php
  • mailer_periodicfollowup.php

谢谢!

【问题讨论】:

    标签: apache .htaccess https rewrite


    【解决方案1】:

    你可以使用:

    RewriteEngine On
    
    RewriteCond %{HTTPS} off
    RewriteRule ^((?!(cron|mailer_confirmjob|mailer_followup|cron_duplicate_check|mailer_periodicfollowup)\.php).*)$ https://%{HTTP_HOST}%{REQUEST_URI} [NC,L,R]
    

    【讨论】:

      猜你喜欢
      • 2015-03-19
      • 2017-11-15
      • 2014-04-27
      • 1970-01-01
      • 2012-07-18
      • 2016-07-27
      • 1970-01-01
      • 2013-12-03
      • 2012-04-19
      相关资源
      最近更新 更多