在子文件夹中运行 Zend Framework - 默认控制器的问题
我正在启动 Zend 应用程序,需要将其放入子文件夹中,如下所示:
- /subfolder
- 申请
- 公开 ...
我做了以下操作:
- 我在 application.ini 中设置了基本 url:
resources.frontController.baseUrl = "/子文件夹"
- 我将 .htaccess 从 public 文件夹直接移至 /subfolder,同时更改 htaccess 如下:
RewriteEngine 开启 RewriteCond %{REQUEST_FILENAME} -s [或] RewriteCond %{REQUEST_FILENAME} -l [或] RewriteCond %{REQUEST_FILENAME} -d 重写规则 ^.*$ - [NC,L] RewriteRule ^.*$ public/index.php [NC,L]
这就是我所做的一切。一切都按预期进行。我可以添加带有操作视图的控制器博客,并可以通过调用来访问它:
/子文件夹/博客/视图
url 视图助手和其他东西也可以正常工作。唯一不起作用的是默认控制器。所以当我输入:
/subolder/
我得到 403(禁止)。如果我输入
/子文件夹/索引
...它有效。我错过了什么?!
提前致谢! 提比
I am starting a Zend application and I need to put it in a sub folder like this:
- /subfolder
- application
- public
...
I did the following:
- I set the base url in application.ini:
resources.frontController.baseUrl = "/subfolder"
- I moved the .htaccess from the public folder directly into /subfolder, while changing the htaccess as follows:
RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ public/index.php [NC,L]
That's all I did. And everything works as expected. I can add controller blog with action view and can access it by calling:
/subfolder/blog/view
the url view helper and stuff work right too. The only thing that does not work is the default controller. So when I enter:
/subolder/
I get 403 (forbidden). If I enter
/subfolder/index
...it works. What am I missing?!
Thanks in advance!
teebee
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不需要在 zf 公共文件夹中进行任何更改,只需使用以下几行在“/subfolder”目录中创建一个 .htaccess 文件
you do not need to make any change in your zf public folder, just create an .htaccess file into the "/subfolder" directory with the following lines
代替
RewriteRule ^.$ public/index.php [NC,L]
和
RewriteRule ^.$ http://addressto/index.php [R=302,NC]
或者
RewriteRule ^.*$ /public/index.php [NC,L]
我不确定将 public 之外的 ZF 文件夹放入可公开访问的文件夹中是否正确。这会给您的网站带来安全漏洞。您必须将 ZF 的公用文件夹的内容放入服务器的公用文件夹中,并将其他文件夹放入非公开访问的文件夹中。如果您需要多个 ZF 应用程序实例,您可以使用 Zend 模块系统。请参阅 zend online文档以获取更多详细信息。
Replace
RewriteRule ^.$ public/index.php [NC,L]
with
RewriteRule ^.$ http://addressto/index.php [R=302,NC]
or
RewriteRule ^.*$ /public/index.php [NC,L]
i'm not sure if putting ZF folders other than public into publicly accessible folder is right.It will impose your site on security flaws. You must put ZF'S public folder' contents into your server`s public folder and put other folders into a non-publicly accessible folder.If you need more that one instance of your ZF application you may use Zend module system.Please refer to zend online documentation for more details.