Reputation: 6677
am in the process to recover a web site which allows upload via admin panel to only allow the index.php script in the public folder. What has been bothering me is that i use ckeditor+pgrfilemanager which are in public folder and contains php files which are needed.
based on suggestion of very knowledgeable people in SO i was sent a reference to this .htaccess snippet:
RewiteEngine On
RewriteCond %{REQUEST_METHOD} ^PUT$ [OR]
RewriteCond %{REQUEST_METHOD} ^MOVE$
RewriteRule ^/public/(.*)\.php /public/$1.nophp
my question is how will this affects php files in the children folder of public ?
Another issue is that i'm really not sure how my final .htaccess for the ZF project you look like.currently reading the .htaccess manual as am not really familiar with it so not sure about my changes
here is what i would like to put up
SetEnv APPLICATION_ENV production
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
RewriteCond %{REQUEST_METHOD} ^PUT$ [OR]
RewriteCond %{REQUEST_METHOD} ^MOVE$
RewriteRule ^/public/(.*)\.php /public/$1.nophp
AddHandler cgi-script .html .htm .shtml .php .php3 .phtml .phtm .pl .py .cgi .js .sh .jsp .asp
Options -ExecCGI
I would be glad if i could learn from people with experience. Thank you
Upvotes: 0
Views: 2614
Reputation: 8218
If there are real children folders in public
then the root .htaccess file will not affect files in there. Apache finds the folder that is lowest and looks there for directives.
The different components in your .htaccess file look OK, but they are out of order. Something like this would be better:
SetEnv APPLICATION_ENV production
AddHandler cgi-script .html .htm .shtml .php .php3 .phtml .phtm .pl .py .cgi .js .sh .jsp .asp
Options -ExecCGI
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_METHOD} ^PUT$ [OR]
RewriteCond %{REQUEST_METHOD} ^MOVE$
RewriteRule ^/public/(.*)\.php /public/$1.nophp [L]
RewriteRule ^.*$ index.php [NC,L]
Upvotes: 1