【问题标题】:htaccess https off conditionhtaccess https 关闭条件
【发布时间】:2013-02-07 06:51:05
【问题描述】:

我创建了以下条件:

DirectoryIndex index.php
RewriteEngine on

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/(shop|delivery-checkout|delivery-order|delivery-offer|confirm-sms-code|show-delivery-product|auto-search-product|add-product|update-product|remove-product|destroy-cart|get-cart|cuisine|og-shop) [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

RewriteCond %{HTTPS} on 
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/ [R=301,L]

RewriteCond $1 !^(index\.php|robots\.txt|website|shop_files|shop_list|client|favicon\.ico|style\.css|sitemap.xml)
RewriteRule ^(.*)$ ./index.php?/$1 [L]

AddCharset utf-8 .js

我基本上要做的是检查 URL 中是否不存在 (https)。
所以除了引用的网址,改写成https://www.

注意:我正在 iframe 中加载这些网址:domain.com/shop、domain.com/delivery-checkout、domain.com/delivery-order 和这就是为什么我希望那些被排除和安全的原因取决于父站点。

我做错了什么?

【问题讨论】:

    标签: .htaccess codeigniter codeigniter-2


    【解决方案1】:

    用这个改变你的代码:

    RewriteCond %{HTTPS} off
    RewriteCond %{REQUEST_URI} !^/(shop|delivery-checkout|delivery-order) [NC]
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
    

    【讨论】:

    • 我仍然在 iframe 中看到一个空白页。如果我commnet这些行它工作正常。此外,商店 uri 可以是这样的:domain.com/shop/1123441241。我不知道这是否值得一提。
    • 这个 URL 不能这样访问。它在 iframe 中加载。因此,如果 iframe 具有 https,它会使用 https 加载。如果 iframe 有 http,它会使用 http 加载。现在使用您的条件,它会给出一个空白页。所以这个想法是使用 https 加载每个页面,除了提到的 URL(商店、交付结帐、...、...),如果 https 关闭。
    • 刚测试,改成https了。
    • 好的@anubhava,我粘贴了完整的htaccess文件。到目前为止,感谢您的帮助。
    • 我评论了规则和条件。使用 http://www.domain.com/index.php/shop/12412341234 转为 https。对排除的 URI 进行 htaccess 测试后,我得到了“不满足此条件”。
    猜你喜欢
    • 2017-04-26
    • 2012-11-19
    • 2012-09-30
    • 1970-01-01
    • 1970-01-01
    • 2012-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多