Reputation: 19
The .htaccess
in my root directory is
Order deny,allow
Deny from all
ErrorDocument 404 /error/index.html
And in error/
the .htaccess
is
Order deny,allow
Allow from all
When I open error/index.html
in a browser normally everything is fine, but when opening after a 404 redirection the images don't load unless I specify them as an absolute path. I presume even though the file is /error/index.html
, it is being run in the directory from which the user is redirected, which does not contain the desired image files (which are located in error/
). Is there any way to use paths relative to the ErrorDocument
after .htaccess
redirection?
Upvotes: 1
Views: 539
Reputation: 786031
While the better fix is always to use absolute path but you can also use <base>
tag.
Try adding this in your page's HTML header:
<base href="/" />
so that every relative URL is resolved from that URL and not the current URL.
Upvotes: 2