how to block php in a folder

Discussion in 'PHP' started by asela_05085, Aug 31, 2009.

  1. #1
    hi,
    I'm totally new to this so pls excuse if this is not the right place to post this.

    i have a Apache web server on linux machine and in some folders i want to block uploading PHP files for some user groups(connect through ftp). so only static files will be available in that folder (administrator may upload PHP files in same folder)

    is there a way to do this.
    pls advice

    rgds
    asela
     
    asela_05085, Aug 31, 2009 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    Is ur server dedicated ??
     
    Bohra, Aug 31, 2009 IP
  3. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Put this in a .htaccess file (make sure the user cannot delete it..) in the root dir:

    
    <IfModule mod_php4.c>
    php_flag engine off
    </IfModule>
    <IfModule mod_php5.c>
    php_flag engine off
    </IfModule>
    
    Code (markup):
    Or in httpd.conf

    <Directory "/home/user/public_html/directory">
    php_flag engine off
    </Directory>

    Or in the user's php.ini if you're using phpsuexec

    engine=off
     
    premiumscripts, Aug 31, 2009 IP
  4. asela_05085

    asela_05085 Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    yes it's a dedicated server.

    i have done the given changes in httpd.conf file earlier.
    it stop executing php in same folder. but if i put a xhtml file with php links to another folder, the execution was not as expected. it asks to save the file in the mobile device than showing the content in the file.

    does the

    "Or in the user's php.ini if you're using phpsuexec
    engine=off"


    option disable php in all folders except the required folder?

    i haven't try the htaccess option yet.
     
    asela_05085, Aug 31, 2009 IP
  5. asela_05085

    asela_05085 Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    the htaccess option is not working for me.
    could someone brief it?

    thanks
     
    asela_05085, Sep 1, 2009 IP
  6. HivelocityDD

    HivelocityDD Peon

    Messages:
    179
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    The aboce option will off the php engine so it will not execute .. As there is no setting for the mime type to identify this as php file it will ask for saving the file.
     
    HivelocityDD, Sep 1, 2009 IP
  7. asela_05085

    asela_05085 Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    is there any other alternative methods to block uploading php files in a folder.
    if possible to block certain user group from uploading php files to a certain folder through FTP then that's enough for the time being.

    pls help someone

    thanks
     
    asela_05085, Sep 1, 2009 IP
  8. picos

    picos Active Member

    Messages:
    155
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    81
    #8
    CHMOD .hta to 444.
    I think, changing php.ini is not required.
     
    picos, Sep 1, 2009 IP
  9. picos

    picos Active Member

    Messages:
    155
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    81
    #9
    CHMOD .hta to 444.
    I think, changing php.ini is not required.
     
    picos, Sep 1, 2009 IP
  10. asela_05085

    asela_05085 Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    this is what i have understood.
    create a file name .htaccess in the required folder and paste the below code in it.
    but seems it doesn't working.
    do i have to restart the service or make any other changes?
     
    asela_05085, Sep 1, 2009 IP