这是因为您使用的是资源(CSS、JS 和图像文件)的相对路径。您需要使用相对根(以斜杠开头)或绝对 URL。
或者,使用部分base
中的元素head
告诉浏览器相对 URL 是相对于什么。例如:
<base href="http://example.com/">
(但请注意,base
如果您有页内锚点,href="#top"
或者需要支持 IE6,则在使用标签时需要注意事项?!)
但是,如果您输入不同的路径http://example.com/another/test.html
,也会出现 404 页面,但指向 css 和图像的链接会损坏。
例如,当您期望它与文档根目录相关时css/normalize.css
,此地址的页面中的 URL 将解析为。http://example.com/another/css/normalize.css
此外,该 URL 有时会解析为http://example.com/example.com/kontakt
其中包含实际域example.com
。
这听起来像您缺少某些链接中的方案,例如:
<a href="example.com/kontakt">Link Text</a>
而它应该是:
<a href="http://example.com/kontakt">Link Text</a>
或者,协议相关:
<a href="//example.com/kontakt">Link Text</a>
另请参阅我在 Pro Webmasters 堆栈上对这个问题的回答:
https ://webmasters.stackexchange.com/questions/86450/htaccess-rewrite-url-leads-to-missing-css