404 error handling with htaccess and css

2019-08-10 19:59发布

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条回答
倾城 Initia
2楼-- · 2019-08-10 20:30

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" />
查看更多
登录 后发表回答