html - 篡改 URL 后 CSS 未加载

标签 html url css url-rewriting

我在本地主机上运行我的测试站点。
当我用 URL 加载它时:
localhost/projects/forums/index.php

enter image description here

它看起来像这样(符合预期)
但是当

我给 URL:
localhost/project/forums/index.php/ (/在 index.php 之后)

CSS 不加载。

enter image description here

看起来像这样。

谁能告诉我如何解决这个问题?
我在很多网站上都看到了同样的问题。

最佳答案

或者:

  • 不要坚持/在页面 URL 的末尾
  • 测试脚本中的 URL,如果它不是您要使用的规范 URL,则进行 301 重定向
  • 对于您的链接(包括 <link> s),使用根相对 URL 而不是当前文档相对 URL(即以 / 开头的 URL)

我会自己使用这三个。

关于html - 篡改 URL 后 CSS 未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14292091/

相关文章:

c# - HttpUtility.UrlEncode - 减号而不是加号?

css - 嵌入 CSS 样式?

html - 如何用css从下到上垂直书写

html - 链接不适用于简单的下拉菜单

javascript - 如何设置打印内容的高度?

javascript - 使 child 的高度大于 parent

javascript - 单击索引中的链接后更改不同页面上的事件类 onClick?

css - 默认居中对齐 DIV 并左对齐

url - Nginx 和相对路径

java - 线程中的异常 "main"org.json.JSONException : A JSONObject text must begin with '{' at 1 [character 2 line 1]