Jump to content

Prevent PHP code exec in subfolders


tibiz

Recommended Posts

Hello,

 

I have a directory tree for my project:

 

/www/CMS/

/www/CMS/files/

/www/CMS/files/Images

/www/CMS/files/Documents

 

The user is able to access content and subfolders files/ via FTP, which is the place for his stuff

 

My question is, how can I prevent running php scripts in files/ , files/Images/ , files/Documents/ using .htaccess

because I tried run a <?php echo get_file_contets("../../index.php"); ?>  in /www/CMS/files/Images/ and it displayed my code;

 

I have a .htaccess file:

  RemoveHandler .php .phtml .php3 .php5

  RemoveType .php .phtml .php3 .php5

  php_flag engine off

but if place it in /www/CMS/ it stops running my project; if I place it in /www/CMS/files/ , the htaccess can be simply deleted by user via ftp

 

thank you for any help

Link to comment
Share on other sites

(same question but simplier way)

 

how setup .htaccess to apply functions:

  RemoveHandler .php .phtml .php3 .php5

  RemoveType .php .phtml .php3 .php5

  php_flag engine off

only to subfolder .../files/ and it's content but the .htaccess must be placed in root directory

Link to comment
Share on other sites

thank you for answer.

 

modification of httpd.conf and setting ownership is not possible on my hosting. I not running on own web server. So the last option is to set up .htaccess to affect with settings the subdirectories , but exclude the root directory where the .htaccess is.

 

The only known good and working situation is (but don't like it):

 

</root/>

  *.php all CMS files

</root/subdir1/>

          *.htaccess disabling running scripts as described in my previous post

</root/subdir1/subdir2/>

                        the place for all 3d-party user's stuff accessable via FTP

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.