Jump to content
Sign in to follow this  
Mudsaf

htaccess allow files included only with PHP

Recommended Posts

Hey, im wondering is it possible to prevent user to go straight to example scripts/php/myscript1.php, but allowed to include with php.

<?php// Example index.phpinclude 'scripts/php/myscript1.php';?>

Share this post


Link to post
Share on other sites

You can use .htaccess to deny http access to a whole directory. PHP would still have system access, such as include.

Share this post


Link to post
Share on other sites
<Directory myfolder1/myfolder/>order allow,denydeny from all<Directory>

This gave my whole website 500 internal server error. I would like it on every php file on that folder except one. Example myfile.php should be accessed.

Share this post


Link to post
Share on other sites

Move those files behind the public directory. Not sure what your folder name is but, it looks like public_html/scripts/php/myscript1.php right now. So make a folder next to public_html called scripts/ now your include will be include '../scripts/php/myscript1.php'. No need for any .htaccess, plus the .htaccess file still exposes your directory structure. Solution, move all PHP behind the public wall making it impossible to access from the browser directly

/home/user/public_html/ *all website, html, js, css, images*/home/user/scripts/ *php and such here*

Edited by chasethemetal

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...