404 error handling with htaccess and css

孤街浪徒 提交于 2019-12-24 13:26:19

问题


hello i have a problem with my 404 error handling.

i added to htaccess:

ErrorDocument 404 /404.php

so in case of typing something like:

www.domain.com/abc

everything works fine with my php page. the problem will be when typing something like:

www.domain.com/abc/

means adding a slash to the url the 404 error page appears but doesn*t load the css file?

if there is someone who could tell me whats going wrong over here, i really would appreciate.

thanks alot.


回答1:


Since the 404 page will be displayed from any URL, you will need to use absolute paths for any external page assets like CSS files, images, JavaScript files, etc.

So any relative paths...

<link type="text/css" rel="stylesheet" media="screen" href="site.css" />

will need to be changed to absolute paths...

<link type="text/css" rel="stylesheet" media="screen" href="/site.css" />


来源:https://stackoverflow.com/questions/13734654/404-error-handling-with-htaccess-and-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!