我怎样才能使用'#'而不是“?”使用 mod_rewrite
我在网站上使用 js 来加载页面,而无需重新加载布局。由于可以在 Facebook 上共享链接,我必须将参数显示为哈希(我不能将参数作为查询字符串给出,否则页面将重新加载)。如何将 mywebsite.com/#query=string
重写为 mywebsite.com/?query=string
?
I use js on my website to load pages without reloading the layout. Because of the possibility of sharing the links on facebook, I had to show the params as a hash (i cant give the params as query string, otherwise the page will be reloaded). How can i rewrite mywebsite.com/#query=string
to mywebsite.com/?query=string
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不能,因为 URL 片段永远不会发送到服务器。您将需要使用 XHR 从服务器加载适当的内容。
You can't, since the URL fragment is never sent to the server. You will need to use XHR to load the appropriate content from the server.
你的服务器永远不会看到哈希部分,浏览器不会将其作为 HTTP 请求的一部分发送,所以你不可能使用 mod_rewrite 来做到这一点。
Your server will never see the hash part, browsers don't send that as part of HTTP request, so no way you'd do that with mod_rewrite.
除了之前所说的:
In addition to all saying earlier :