dongqian6554 2014-04-10 23:16
浏览 17

如何将从数据库检索的链接指向PHP中的绝对路径,以便它可以工作?

I have a database that stores the link. This value "link" is later read by my script and a user can click on a link to go to that link.

The links work with no issue when the user is on any page that is saved/hosted in the root directory /myroot/

But when a user clicks on the link while on a page the is saved/hosted on a different path saved on (ie. /myroot/news/feed.php) the link does not work.. "it seems to me that the script is not ale to tell where it is currently located so it does not know where to take you)

I tried to provide the root path of the site (ie. /myroot/{the link} but that did not work either.

How can I fix the URL so that the script knows where is the true location of the file?

thanks

  • 写回答

1条回答 默认 最新

  • doulan6150 2014-04-11 01:18
    关注

    You need to specify a starting point so you can give absolute links instead of relative links. Look through the $_SERVER[] array, there are some elements that tell you where your directory location is on your site.

    评论

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答