繁体   English   中英

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

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

正在恢复网站的过程中,该网站允许通过管理面板上载仅允许公用文件夹中的index.php脚本。 困扰我的是,我使用ckeditor + pgrfilemanager放在公共文件夹中,并且包含需要的php文件。

基于SO中非常有知识的人员的建议,我收到了对此.htaccess片段的引用:

RewiteEngine On
RewriteCond %{REQUEST_METHOD} ^PUT$ [OR]
RewriteCond %{REQUEST_METHOD} ^MOVE$
RewriteRule ^/public/(.*)\.php /public/$1.nophp

我的问题是,这将如何影响public的children文件夹中的php文件?

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

这是我想提出的

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

如果我可以向有经验的人学习,我会很高兴。 谢谢

如果public目录中有真正的子文件夹,则根.htaccess文件将不会影响其中的文件。 Apache找到最低的文件夹,并在其中查找指令。

.htaccess文件中的不同组件看起来不错,但是它们顺序不对。 这样的事情会更好:

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