This has been driving me crazy! Im using wordpress and in my htaccess I have the following:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
At the very top of my htaccess I have tried to put; Errordocument /index.php?error=404 and other alternative directions but they either result in page not redirecting or an internal server error etc.
I have seen that many of these have been solved here but I have not found a case where someone has the same code in their htaccess.
I have tried to remove
RewriteRule ^index.php$ - [L]
and
RewriteRule . /index.php [L]
Which gives more errors explaining there was a 404 error trying to find my 404.php or at line 10 of my 404.php at getheader() and it also removes my BWP sitemap entirely.
I am using a child theme but i have copied the 404.php/header/footer/index to the childtheme to make things easy.
Any help will be appreciated
Thanks
Ok I have completely solved this problem, instead of deleting this I will leave it here so it can help others like me who have been stuck with this problem. I finally solved the problem with endless redirection on my 404 error page, this solution will only work for you if you have the following criteria:
your 404 page had to be functional before changing the htaccess
if you have the following criteria all you need to do is remove
anything you have installed or changed that is redirecting HTTP to HTTPS, it may be a plugin that
forces SSL (HTTPS) on all pages or some code in your htaccess (you
should know what you have added or changed).
Once that has been removed go into wordpress and edit your homepage, you will see on the right hand side it will have an enable SSL tickbox (this will redirect HTTP to HTTPS forcing HTTPS for the current page only), simply tick this box and then repeat for all pages that you want to display in SSL (HTTPS), be sure to update all pages that you have changed to SSL (HTTPS) and you are done.
It took me a long time to realise that by doing this I was forcing SSL (HTTPS) on all pages already and that having anything else like a plugin or code snippet in htaccess was just making the loop endless (since wordpress was already redirecting HTTP to HTTPS anything else doing the same would produce an endless loop), and the 404 page was redirecting endlessly becauise the 404 error page only loads in HTTP and not HTTPS making it a target for redirection by force SSL (HTTPS) plugins or code snippets.
After realising this I can see another way to fix this would be to have the 404 error page load in HTTPS.
I hope this can help someone else even if it is quite obvious.