I am not very firm in Apache, so please excuse if the question might seem a bit obvious. I would like to redirect requests that would result in an Error 403 in specific directories to my webservers root by means of a .htaccess file. so https://thedomain.com/secretlair/ -> https://thedomain.com
so far i used:
RewriteEngine on
RewriteBase /
RewriteRule (.*) https://thedomain.com/$1 [R=301,L]
which works but creates the problem of also redirecting https://thedomain.com/secretlair/thefile.txt to https://thedomain.com/thefile.txt
what do I need to change to make this work?
Thanks a lot!
You can just use a ErrorDocument handler for 403 error instead of a rewrite rule like this:
ErrorDocument 403 https://thedomain.com/
Make sure to clear your browser cache before testing this change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With