>am 正在恢复允许通过管理面板上传的网站,以仅允许公用文件夹中的索引.php脚本。一直困扰我的是我使用ckeditor+pgrfilemanager,它们位于公共文件夹中,并包含所需的php文件。
根据SO中知识渊博的人的建议,我收到了对这个.htaccess片段的引用:
RewiteEngine On
RewriteCond %{REQUEST_METHOD} ^PUT$ [OR]
RewriteCond %{REQUEST_METHOD} ^MOVE$
RewriteRule ^/public/(.*)'.php /public/$1.nophp
我的问题是这将如何影响公共儿童文件夹中的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]