简体   繁体   English

使用RewriteRule将大多数网站重定向到HTTPS

[英]Redirect most of site to HTTPS using RewriteRule

I want my entire site to use HTTPS, except for the home page due to a non-secure script there. 我希望我的整个站点都使用HTTPS,但由于那里的脚本不安全,首页除外。

The site is using Apache/Slim. 该站点正在使用Apache / Slim。

Inside /etc/apache2/sites-available/000-default.conf : /etc/apache2/sites-available/000-default.conf内部:

RewriteCond "%{REQUEST_URI}" “!=/”
RewriteRule . https://%{HTTP:Host}%{REQUEST_URI} [R=302,S=1]

#the usual Slim rule:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php

(Note the S=1 . That is supposed to skip the next rule if there's a match.) (请注意, S=1如果存在匹配项,则应该跳过下一个规则。)

Problem: I'm not being redirected and my css includes are not being served (I just get a copy of the home page html). 问题:我没有被重定向,我的css include也没有被提供(我只是得到主页html的副本)。 Any suggestions? 有什么建议么?

Since I was using CarQuery, I was actually able to simply use CarQuery over HTTPS: 自从我使用CarQuery以来,我实际上可以简单地通过HTTPS使用CarQuery:

Change 更改

<script type="text/javascript" src="http://www.carqueryapi.com/js/carquery.0.3.4.js"></script>

to: 至:

<script type="text/javascript" src="https://www.carqueryapi.com/js/carquery.0.3.4.js"></script>

No more need to write fancy RewriteRules. 不再需要编写精美的RewriteRules。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM