I looking for way to redirect any 404 error into index.php
ErrorDocument 404 /index.php
Works fine until you have a 404 inside another folder /about/non-existing-page.php – in this case it will display index.php but the page will be missing styles (as styles are in the root folder).
Any way I can actually user 301 redirect for ANY (anywhere) 404 error?
As you already said, this is not the redirection page’s fault: it’s your browser that thinks it’s in the
/aboutfolder. There’s nothing you can do in .htaccess to change that: a 301 redirect would change the status code, which is not a good idea.The easiest solution would be using absolute links in the document:
for completeness’ sake, a subsequent 301 can be achieved by using a full URL:
but as said, it’s probably not a good idea.