relative paths in html for ErrorDocument
In my apache2 configuration I have t开发者_C百科he line:
ErrorDocument 404 /404.html
Inside 404.html I have img and style tags like:
<img src="foo.gif">
This works properly only if the non-existent URL is in the root directory... i.e. if I navigate to: http://example.com/does_not_exist
my 404.html displays fine with its images. However, if I navigate to: http://example.com/some_dir/does_not_exist,
I see 404.html but with broken images, because it's trying to serve http://example.com/some_dir/foo.gif instead of http://example.com/foo.gif
Is there a good solution to this?
EDIT: I would prefer not having to use absolute paths in my img and style tags because the web designer I'm working with says that it causes the images and styles to not show up in DreamWeaver. (I don't have DreamWeaver so I don't know what the problem is there)
Can you try changing your link to have a preceding slash:
<img src="/foo.gif">
If you can't do this, then the only think I can think of is writing a RewriteRule so requests to these images are rewritten to point to their actual location, or doing some kind of pre deploy process where image links get substituted. I don't know much about Dreamweaver, but surely there must be a way to get it work with relative paths starting at the server root (which is what I have done with preceding slash above).
EDIT: I just did a quick Google and I think you can configure Dreamweaver to work with site root relative paths (like mine) by doing the "Set up and edit a local root folder" process.
精彩评论