I am using the following .htaccess
file, which works well, however, I want to also forward any attempts to access non-existent files in the root directory and in any subdirectory (whether the subdirectory exists or not) back to the main domain name.
I tried FallbackResource
but that resulted in 500 series errors.
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https://xxxxxxxxx.xxxxx/.*$ [NC]
RewriteRule \.(gif|jpg|jpeg|bmp|zip|rar|mp3|flv|swf|png|css|pdf)$ - [F]
# browser requests PHP
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]
# check to see if the request is for a PHP file:
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/?(.*)$ /$1.php [L]
ErrorDocument 500 /redirect
ErrorDocument 500 /redirect
ErrorDocument 500 /redirect
ErrorDocument 404 /error
ErrorDocument 401 /redirect
ErrorDocument 403 /redirect
Any help would be greatly appreciated.