配置 apache vhost 不处理“?”作为查询令牌
我已经对我的ajax应用程序上的所有页面进行了快照,并按照google规范[http://www.google.com/support/webmasters/bin/answer.py?hl=zh-CN&answer=174992]我已将这些文件存储为“ www.example.com/ajax.html?_escaped_fragment_=mystate" 。 在同一目录中,有一个名为 ajax.html 的文件,适用于此示例,它是一个静态 html 页面。根本不涉及服务器端。
当导航到 www.example.com/ajax.html?_escaped_fragment_=mystate 时,其中包含的 html 内容与 ajax.html 中的内容不同,ajax.html 使用curl、wget 和 google 的“fetch as”显示在浏览器中谷歌机器人”工具。
根据我的理解,问题在于? http 服务器 [apache 2] 处理的方式与浏览器处理 # 的方式相同,即它被视为查询参数字符。
那么,我如何指示此 VHOST 正确运行,并发送 www.example.com/ajax.html?_escaped_fragment_=mystate 文件呢?
谢谢
I have snapshotted all the pages on my ajax application, and as per google specification [ http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=174992 ]i've stored those files in a pattern described as "www.example.com/ajax.html?_escaped_fragment_=mystate" .
In the same directory there is a file named, adapted to this example, ajax.html , which is a static html page. No server side is involved at all.
When navigating to www.example.com/ajax.html?_escaped_fragment_=mystate , which contains html content which is different from that found in ajax.html , ajax.html gets displayed in the browser, using curl, wget and google's "fetch as googlebot" tool.
From my understanding the problem is that ? gets treated by the http server [apache 2] the same way as # gets treated by the browser, ie it's considered as a query param char.
So, how do i instruct this VHOST to behave correctly, and send out the www.example.com/ajax.html?_escaped_fragment_=mystate file instead?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将所有片段保存在 /fragments/(mystate) 中并使用 apache 模块 mod_rewrite:
这读作:
如果存在查询字符串“_escaped_fragment_”,则获取该值,将其放入变量 %1 中并继续。然后,如果 url 也是“ajax.html”,则将 ajax.html 重写为 /fragments/%1。
You could save all your fragments in /fragments/(mystate) and use the apache module mod_rewrite:
This reads as:
If theres a query string "_escaped_fragment_", take the value, put it in variable %1 and go on. Then, if the url also is 'ajax.html' Rewrite ajax.html to /fragments/%1.