Home > Net >  Allow my other pages to access a dir restricted with .htaccess
Allow my other pages to access a dir restricted with .htaccess

Time:06-05

I have some sensitive pages which I dont want to expose to external users. So I have put them in a folder (say xyz) and restricted the access with .htaccess for entire folder. Now lets say user have access to index.php

Is there a way for index.php to source some files from xyz and those files to remain restricted from external user.

So the structure is:

  html
   |
   |- index.php
   |- xyz
      |- .htaccess
      |- myfunctions.php
      |- myadminpage.php

Can index.php source myfunctions.php inside it?

   require_once 'xyz/myfunctions.php'

CodePudding user response:

Can index.php source myfunctions.php inside it?

require_once 'xyz/myfunctions.php'

Yes.

.htaccess only applies to HTTP traffic. An internal request on the server (via require, include, fopen, etc. *1) bypasses .htaccess (except in some unusual server configs).

(*1 assuming you're not requesting the file over HTTP, ie. using URL-wrappers.)

  • Related