如何修复 Drupal 站点中的此错误?

how to fix this error in Drupal Site?

我有 Drupal 6 站点。

这是我的网址:-

  1. www.mysite.com/albums
  2. www.mysite.com/albums/印地语

在我的page.tpl.php,在header

<link rel="stylesheet" type="text/css" href="<?php echo path_to_theme(); ?>/css/bootstrap/css/bootstrap.min.css" />

现在,如果我输入 url www.mysite.com/albums,样式表将被毫无问题地选取和呈现。

但如果我输入 url 作为 www.mysite。com/albums/( / 最后)或任何内页说 www.mysite.com/albums/hindi,缺少样式表

如果我检查页面并在样式表路径中手动放置 /,它会再次呈现。

这不仅仅是样式表的问题,还有脚本 + 图像的问题。

我有时会在 chrome 中收到警告消息,因为

Resource interpreted as Stylesheet but transferred with MIME type text/html

我应该怎么做才能解决它?

我正在使用 Drupal v6.0

注意:社区不再正式支持 Drupal 6。虽然有些地方为 Drupal 6 提供长期支持,但您应该计划尽快迁移到 Drupal 7 或 8。

您似乎有两个问题:CSS 文件的路径和网络服务器为 CSS 文件发送的 headers。您提到的主要问题是 CSS 路径,因此此处的大部分信息都与此有关。

path_to_theme() provides a reference that is relative to Drupal root, which is usually the site root (/) but could be something else if Drupal is running in a sub directory or some other configuration. You need to prepend the result of base_path() 如果您要对 link.

进行硬编码

使用 drupal_add_css() from within a hook in your module or template.php instead of hard-coding the link in a tpl.php file. Drupal_add_css() allows Drupal to process your CSS through its built-in aggregation. The hook_preprocess_HOOK() 函数几乎总是更好,这是添加 CSS 和 JS 文件的常见位置。

MIME 类型通知可能是由于 Web 服务器未正确检测 CSS 文件并设置正确的 headers。解决方法取决于您的 Web 服务器选择和托管环境(Google 应该可以帮助您找到问题并解决它)。