簡體   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