I have the “public_html” folder and a subfolder called “login” with the index.php that asks for the username and password.
I need to protect the subfolder contents from malicious bot requests and I thought to redirect|rewrite all the request URIs that contain the “login/” string to the login index.php.
I wrote these lines in the .htaccess inside the public_html:
RewriteEngine on
RewriteRule %{HTTP_HOST}/login/(.*) /login/index.php [L]
But it doesn’t work because if I write www.mysite.com/login/js/tinymce/something.php it doesn’t rewrite anything.
2
Answers
I have a similar rewriterule on a system I maintain.
Can you try this and see if it helps?
In theory it should redirect everything that starts /login to the index.php file in that folder.
Hmmm… maybe its a syntax error of the regular expression used in the configuration file, maybe try this:
Also this site regexr.com is a amazing debugger for regular expression
Image from the same case