I am trying to preserve my PHP files against direct access. What I want to give permission is direct access to a directory (CSS, images, etc.) called index.php and public . Access to root directory / should be redirected to index.php :
/ (root): permissions - & gt; Redirect to index.php - index.php: Permission + - Public | + --... Allow + - [Rest of all]: Block My current .htaccess file looks like this:
Allow the order, refuse & lt; Files index.php & gt; All & lt; / Files & gt; Allow from & lt; Files Htaccess & gt; Allow orders, from all & lt; / Files & gt; DirectoryIndex index.php & lt; IfModule mod_rewrite.c & gt; RivetIngnin on River Rule ^ / $ / Indix.fpp [L] & lt; / IfModule & gt; It works basically but will not redirect from / to index.php , instead Apache was giving me a 403 error is. What am i doing
order ... , which you can find.
Allow, Decline
First of all, allow all instructions; Must have at least one match, or the request has been rejected. Next, all prohibition instructions are evaluated. If any matches, the request is rejected. Last, any request that does not match the permission or prohibit instruction, is rejected by default. The request for
/ does not match any rule, so the instructions for it have not been rejected or rejected, so it's default As you have rejected it, you clear it by allowing it to explicitly allow the request of / , and to allow requests, create a new .htaccess file in the public subdirectory. / Htaccess in
:
Allow the order, reject it; Files ~ "^ (index \ .php |) $" & gt; All & lt; / Files & gt; Allow from & lt; Files Htaccess & gt; Allow orders, from all & lt; / Files & gt; DirectoryIndex index.php and /public/.htaccess :
Allow commands, deny Allow all from Screencast of this work:
No comments:
Post a Comment