重写 url 以进行深度链接
我想做的事情非常简单,但没有一个 stackoverflow 答案能够准确解决这个问题:
How do i use .htaccess to insert a hash tag in between the base url and the Route requests?
ie
http://mydomain.com/shop
将成为
http://mydomain.com/#/shop
我想使用 .htaccess 因为我觉得它比服务器端 php 更干净的解决方案。 我可以这样做的原因是因为我使用 jquery 地址来接管页面上的链接,替换 href 属性。如果哈希标签没有正确放入,它就会中断。
What i'm trying to do is quite simple but none of the stackoverflow answers address this exactly:
How do i use .htaccess to insert a hash tag in between the base url and the route requested?
ie
http://mydomain.com/shop
will become
http://mydomain.com/#/shop
i want to use .htaccess because i feel like its a cleaner solution than server side php.
it the reason i can do this is because i'm using jquery address which takes over the links on the page replacing the href attribute. it just breaks if the hash tag isn't properly getting put in.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需使用 bog-standard mod_rewrite 和“no-escape”(NE)选项:
Just use bog-standard mod_rewrite with the "no-escape" (NE) option:
哈希/数字符号 (#) 本身在 URL 中具有特殊意义,因此您无法可靠地将其放入您的 URL 的路径中。你可以这样做:
The hash/number symbol (#) itself has a special significance in a URL, so you cannot reliably place it into the path of your URL. You can do this:
下面的代码有助于深度链接。如果未安装该模块,您需要验证浏览器并重定向到应用程序商店,如果安装意味着它将重定向到应用程序内部。
Below code is helpful for deeplinking.You need to validate the browser and redirect to the app store if the module is not installed ,if installed means it will redirect to inside the app.