【问题标题】:ignore url mod-rewrite via htaccess通过 htaccess 忽略 url mod-rewrite
【发布时间】:2015-02-25 06:33:31
【问题描述】:

我使用 Prestashop 并为所有 url 强制使用 https。

我需要用这个 url 添加脚本: src="//c.imedia.cz/js/retargeting.js" 我需要 url 在 html 中保持这样。

但 htaccess 似乎将其更改为 src="https://c.imedia.cz/js/retargeting.js" 那就不行了。

我尝试添加重写规则以防止覆盖此 url

RewriteRule retargeting\.js$ - [L,NC]

请问有什么解决办法吗?

【问题讨论】:

    标签: .htaccess mod-rewrite ssl https


    【解决方案1】:

    htaccess 不会更改 HTML 中的 src浏览器 会将// 替换为请求中使用的协议。即https。通常称为protocol relative URL

    More info in this answer about that

    因此,如果您不希望它使用https,那么您应该明确地将其设置为http。然而,当通过https 提供服务时,这将导致混合内容,现代浏览器可能会阻止它。所以如果你强制https,那么ALL你的资源也必须是https,否则即使使用http,它也会被阻止并且不会加载。

    那么您应该为您的子域获得一个通配符 SSL 证书,以便您的资源也可以作为 https 提供。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-21
      • 2014-09-26
      • 1970-01-01
      • 2012-10-03
      • 1970-01-01
      相关资源
      最近更新 更多