protect php includes (with htaccess?)

后端 未结 5 1021
清酒与你
清酒与你 2020-12-18 12:38

First of all, I\'m pretty sure a similar question will be on Stack Overflow, but I didn\'t really find it. Probably because I am using the wrong keywords. So don\'t shoot me

5条回答
  •  心在旅途
    2020-12-18 13:29

    Hmm, as already mentioned, htaccess will not prevent php from accessing htpassword secured folders. Consequently, Apache has to be invoked in order to use it's security features which are quite secure, at least with https IMHO, eg:

    header('Location: secret/index.php');
    

    Where the folder secret is secured with htaccess.

    index.php might look like this:

    
    

    And secret/index.php

    
    

    The main remaining problem is now, that secret/index.php will not find any links like ./main.css etc. Therefore links have to be defined absolute not relative, but I am sure that you guys now how to do that;-)

    A running example is on http://promotio.ch/secret.php/

提交回复
热议问题