将 History.js 与 mod_rewriting URL 一起使用
我的搜索页面位于 http://www.example.com/search_result.php,我将其 mod_rewriting 为 http://www.example.com/search-result 。
发生的情况是这样的:如果我重写的 URL 以 /
结尾,HTML4 浏览器就会进入无限 URL 循环,将字符串附加到 URL 末尾。如果没有,我会在 HTML5 浏览器中丢失 URL 的 search-result
部分,并且在语句中添加 "search-result/
也会将其添加到 < code># 在 HTML4 浏览器中,
如果我更改基本标签,页面会在 /search-result/
所以我完蛋了。
那么,我该如何解决这个问题?或者我应该寻找另一个库?有 RSH,但它自 2007 年以来就没有更新过......
I have a search page located at http://www.example.com/search_result.php, and I'm mod_rewriting it to be http://www.example.com/search-result.
Basically, I want to do what the History.js demo does - append an arbitrary string to the end of the URL (with a #
if it's a HTML4 browser). The demo works great in my browser's - however, my site's <base>
tag points to the root directory on all pages, and I think that's what's breaking my site's behaviour.
Here's what happens: If my rewritten URL ends with a /
, HTML4 browsers go into an infinite URL loop of appending the string to the end of the URL. If it doesn't, I lose the search-result
portion of my URL in HTML5 browsers, and adding "search-result/
to the statement also adds it after the #
in HTML4 browsers.
And If I change the base tag, the page looks for its files (CSS, JS, images, everything) in the nonexistent directory of /search-result/
. So I'm screwed.
So, how do I fix this? Or should I be looking for another library? There's RSH, but it hasn't been updated since 2007...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用类似的方法从重写中排除特定目录吗?
Could you use something like this where you exclude specific directories from the rewrite?