【发布时间】:2015-09-02 07:20:44
【问题描述】:
我有这个脚本,它运行良好,但如果 URL 是这样的,它会重定向到 Google:
http://example.com/test/examples
if (window.location.href.indexOf("/test") > -1) {
window.location.href="http://google.hu";
}
如果我在 /test/ 之后有单词,我不想重定向。
所以我需要这个:
http://example.com/test/examples --> 不重定向
http://example.com/test ---> 重定向
我如何用 jQuery 做到这一点?
【问题讨论】:
-
最好在服务器上做重定向;客户端并不总是支持 JavaScript 或基于客户端的重定向。