apache - .htaccess - Deny access to folder but allow access to file via index.php -


I'm having problems with .htaccess and PHP-files in a subfolder. What I am trying to achieve is to prevent any file from accessing it in my sub folder - but I want my index.php to access those files.

  DOCROOT / subfolder - & gt; Www.somewebsite.com/subfolder/somefile.php - & gt; Access denied  

but

  [index.php] & lt; Form action = "/ subfolder / somefile.php" & gt; ... & lt; / Form & gt; - & gt; Success!  

I would love to solve it just by using .htaccess. I tried deny all and some again s but those rules also kill any request from index.php. I tried

  deny the order, Allow all to reject Allow from 127.0.0.1 Allow from somewebsite.com Any satisfied  

but request from index.php is being denied. Can anyone help, please?

This is a misconception that people have only because you have links from the PHP file It does not mean that index.php file is reaching them from any other PHP file. To access the end user / browser still , it is only telling where your index.php file goes from where it is being used There is absolutely nothing along. In both of your cases, they are being accessed by the browser.

The best you can do is to look at the referrer field. It can be easily latticed to get around this, but this is the only thing you can do.

  RewriteEngine On RewriteCond% {HTTP_REFERER}! Https ?: // (example.com | 127 \ .0 \ .0 \ .1) [NC] rewritable ^ subfolder / - [LF]  

where "example.com "Your site is.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -