I'm currently having an issue with my .htaccess file.
I have set some ErrorDocument
s and in order to have my own files to show when an error is occuring but I'm having an issue with the 404.
I'm pretty sure that my .htaccess file is corrupted as I've put some random stuff I don't always understand (even if I still understand what they do).
Here's the code:
# Allow Rewrite
RewriteEngine On
# Rewrite base
RewriteCond %{HTTP_HOST} ^thehalcyon.tk [NC]
RewriteRule ^(.*)$ http://www.thehalcyon.tk/?$1 [L,R=301,NC]
# Resource access
RewriteRule ^(design|js|images)($|/) - [L]
# Rewrite profile path
RewriteRule ^users/([0-9]+)/$ /user.php?p=$1
# Redirect quick URLs to subdomains
RewriteRule ^(brg|brogaming|gaming)/?$ http://brg.thehalcyon.tk/ [R=301,L,NC]
RewriteRule ^(pxlr|pixelated|pixelatedreality|pixelrel|dev)/?$ http://pxlr.thehalcyon.tk/ [R=301,L,NC]
RewriteRule ^(prod|halprod|halcyonprod|av)/?$ http://prod.thehalcyon.tk/ [R=301,L,NC]
# Path beautifying
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /$1.php
RewriteRule ^([^/]+)/([^/]+)/?$ /$1/$2.php
# 404 redirect if !exists (I have removed this part for the moment)
RewriteCond %{THE_REQUEST} \.php [NC]
RewriteRule ^(?!404\.*)$ - [L,NC,R=404]
# Error Documents Redirect
ErrorDocument 404 http://www.thehalcyon.tk/notFound.php
ErrorDocument 403 http://www.thehalcyon.tk/forbidden.php
ErrorDocument 401 http://www.thehalcyon.tk/unauthorized.php
# Options
Options All +FollowSymLinks
Options All -Indexes
So when I'm trying to access a file that doesn't exist I'm getting an Error 500 rather than an Error 404 and the following message:
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Sometimes it just redirects me to my hosting provider home page, which is really weird.
What I would like, is to redirect the browser to my 404 file whenever they enter a wrong URL, and thus regardless of if there's an extension or not.
I'm quite new to HTACCESS files so I'm having issues I can't understand. Also my host does not allow apache error logs access on free hosting plans so I can't understand where is my mistake.
I would really appreciate if seomone could help me with that. Feel free to visit my website in order to understand what is my issue: http://www.thehalcyon.tk/ (don't pay attention to what's written, it's a French website though)
Thank you in advance for any fellow developper willing to help me.
EDIT: I've cloned my website on a WAMP server and checked the error log. It says too many redirects, probably due to the Path Beautifying rules. When I disable them and use the file extensions (.php) it works. Any way to find a way to combine the two features?