【问题标题】:<base> tag is working in my localhost but not in my website<base> 标签在我的 localhost 中有效,但在我的网站中无效
【发布时间】:2016-12-16 12:04:47
【问题描述】:
<base href="//localhost/virsan/" />
<link href="assets/stylesheets/font.css" rel='stylesheet' type='text/css'>

我在本地主机中使用&lt;base href="//localhost/virsan/" /&gt; 之类的基本标签。

在域中,我像 &lt;base href="virsa.ca/" /&gt; 一样使用它,但它不起作用。

当我在线使用它时,它会给我错误页面 404 URL,例如 http://virsa.ca/collection/neckwear/8/

【问题讨论】:

  • 第一基地 我在本地计算机上的 appache 上使用它,但是当我把它放到网上时,它给了我错误
  • 如果只是URL根路径,base真的有必要吗?我认为 404 错误不是因为基础。
  • base 是必要的,我正在使用函数 function news_link($id, $title) { $slug = $title;返回“集合/$slug/$id/”; } 我的网址

标签: html base-url


【解决方案1】:

试试这个,

<base href="http://virsa.ca/" />

您需要指定完整的网址

【讨论】:

  • @user3682988 查看 css 路径 virsa.ca/assets/stylesheets/font.css 。它已加载
  • 先生,我正在尝试更改 php 中的 url 它更改了 url 但找不到页面
  • 我将我的网址 collection.php?id=8&slug=neckwear 更改为 collection/neckwear/8/
  • @user3682988 问题是您的网址中有一个 index.php 文件。请参阅virsa.ca/index.php/collection/neckwear/8 这个,要做到这一点,你需要在你的路径中指定 index.php。基本网址将是 virsa.ca/index.php
  • index.php 是不同的页面,而 collection.php 是不同的页面 m 试图重写 url:P
【解决方案2】:

尝试从您的浏览器中检查控制台缺少哪些资产以及丢失的原因。 我建议的一件事是检查问题是否来自基本标签。通过避免使用基本标记并使用其完全限定的地址加载资源。

【讨论】:

    猜你喜欢
    • 2018-05-15
    • 2021-05-30
    • 1970-01-01
    • 1970-01-01
    • 2016-11-14
    • 2017-12-29
    • 2023-03-22
    • 2014-06-11
    • 1970-01-01
    相关资源
    最近更新 更多