Nikita Smith Nikita Smith - 1 month ago 5
Apache Configuration Question

404 redirect work on current directory

I decided to take the application of the rules of etiquette for the site,

.htaccess
:

...
# Not found
ErrorDocument 404 /error/404.html
...


It's working, but included
css
and
js
files are connecting on current directory, rather than relative to the root. Resulting in an error loading
css
and
js
files in subdirectories like
mysite.com/item/item/
.




I can solve it like this:

...
# Not found
ErrorDocument 404 mysite.com/error/404.html
...


It will work everywhere, but
url
is changing without chance to back door.

I want to get the same without change
url-address
.

How can I do it?

Answer

Add this in the header of your 404.html

<base href="/">

it works for all links and images included