简体   繁体   English

如何在Zend Framework项目中配置.htaccess以仅允许公用文件夹中的index.php

[英]How to configure .htaccess in a Zend Framework project to allow only index.php in public folder

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. 正在恢复网站的过程中,该网站允许通过管理面板上载仅允许公用文件夹中的index.php脚本。 What has been bothering me is that i use ckeditor+pgrfilemanager which are in public folder and contains php files which are needed. 困扰我的是,我使用ckeditor + pgrfilemanager放在公共文件夹中,并且包含需要的php文件。

based on suggestion of very knowledgeable people in SO i was sent a reference to this .htaccess snippet: 基于SO中非常有知识的人员的建议,我收到了对此.htaccess片段的引用:

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 ? 我的问题是,这将如何影响public的children文件夹中的php文件?

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 另一个问题是我真的不确定我对ZF项目的最终.htaccess效果如何。目前正在阅读.htaccess手册,因为它并不十分熟悉,因此不确定我的更改

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 谢谢

If there are real children folders in public then the root .htaccess file will not affect files in there. 如果public目录中有真正的子文件夹,则根.htaccess文件将不会影响其中的文件。 Apache finds the folder that is lowest and looks there for directives. Apache找到最低的文件夹,并在其中查找指令。

The different components in your .htaccess file look OK, but they are out of order. .htaccess文件中的不同组件看起来不错,但是它们顺序不对。 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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM