【问题标题】:When clicking Home button, url is showing full path instead of just index.php单击主页按钮时,url 显示完整路径,而不仅仅是 index.php
【发布时间】:2019-11-28 20:39:12
【问题描述】:

我刚刚将我的 htdocs 文件夹上传到我的网络托管服务中的 public_html,并且网站可以正常工作,但是当按下主页按钮时,URL 会显示整个服务器路径。

<div>
  <ul>
   <li><a href="index.php">Home</a></li>
   <li><a href="shop.php">Shop</a></li>
   <li><a href="contact.php">Contact</a></li>
   <li><a href="local_stores.php">Local Stores</a></li>
   <li><a href="login.php">Store Login</a></li>
  </ul>
</div>

我希望主页按钮将我带回 mydomain.com 而不是 mydomain.com/home1/company/public_html/mydomain.com

【问题讨论】:

    标签: php html hosting


    【解决方案1】:

    想通了!在使用 XAMP 和文本编辑器进行开发时,您在 a 标签中使用“index.php”和“otherpage.php”。但是在托管服务中,要返回“index.php”,href 值应该是“/”,因为它会自动在它所在的目录中查找 index.php。

    我使用这个堆栈线程解决了这个问题:

    Link to index page of website

    【讨论】:

      【解决方案2】:

      当您只输入文件名时,html 总是在路径前面。
      尝试使用&lt;a href=“/index.php“&gt;Home&lt;a&gt;

      / 告诉浏览器去 domain.tld/index.php

      【讨论】:

      • 它不起作用:/它不会为另一个其他链接添加前缀。仅适用于 index.php,即使我使用 /
      猜你喜欢
      • 2016-08-16
      • 1970-01-01
      • 1970-01-01
      • 2022-07-15
      • 2023-03-25
      • 2013-07-14
      • 1970-01-01
      • 2012-01-21
      • 2022-07-05
      相关资源
      最近更新 更多