我想重写 http://example.com/articles.html#first-article
与 http://example.com/文章/第一条
是否有可能重写?
我尝试使用下面的,但对我没有工作:
重写规则^文章/(.+)$ /articles.html#$1
解决方案
没有,这是不可能的。在网址片段的(一切从#
上)甚至没有被发送到服务器。
也许你要考虑一种基于JavaScript的解决方案,其中实际的内容将通过AJAX加载依赖的片段上。你会发现这里这个方法的一些有用的信息:What's该家当/ hashbang在Facebook和Twitter的新网址(#!)什么?
I want to rewrite http://example.com/articles.html#first-article
with http://example.com/articles/first-article
Is it possible to rewrite?
I tried using following but didn't work for me:
RewriteRule ^articles/(.+)$ /articles.html#$1
解决方案
No, it's not possible. The URL fragment (everything from #
on) not even gets sent to the server.
Maybe you want to consider a JavaScript based solution, where the actual content will be loaded via AJAX dependent on the fragment. You will find some useful information about this method here: What's the shebang/hashbang (#!) in Facebook and new Twitter URLs for?