我正在使用Altorouter,它需要htacess中的以下内容
$("body *").html(function(_, text) {
if (!this.children.length) {
return text.replace(/foo/g, '<span class="fixed">bar</span>')
}
else {
var el = this;
for (var i = 0; i < el.childNodes.length; i++) {
var node = el.childNodes[i];
if (node.nodeName === "#text") {
var span = document.createElement("span");
span.textContent = node.textContent.replace(/foo/g, "bar");
span.className = "fixed";
node.parentNode.replaceChild(span, node);
}
}
}
})
这工作正常,但我还需要将http重定向到https。我在网上找到了例子但是我把所有这两个组合起来的努力都失败了。我如何将顶部片段与此结合起来?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
</script>
<p><a class="foo" id="foo" href="foo.html">foo</a>foo</p>
<h3><a id="foo" name="foo">About foo</a></h3>
答案 0 :(得分:2)
尝试以下,
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]