Symfony 忽略 web/ 中的目录
在 symfony 项目中,有什么方法可以排除目录被处理。
例如,我想在 mysite.com/other_app 中运行一个单独的 php 程序,
如何排除 symfony 控制器处理的 web/other_app 文件夹。
我尝试过使用
RewriteCond %{REQUEST_URI} !^/other_app/(.*)$
和
RewriteCond %{REQUEST_FILENAME} !-d
Symfony 仍然处理 other_app ,这显然无法正常工作。有什么建议吗?我还需要修改 other_app/.htaccess 中的 htaccess 吗?
另外,我补充一下。当我仅访问目录 mysite.com/other_app 时,我得到了正确的内容。如果我尝试访问低于该值的任何内容,我就会遇到问题。
这有效: mysite.com/other_app
这不会: mysite.com/other_app/page1
在日志中我收到错误: 操作“other_app/page1”不存在。或者类似的东西。
In an symfony project, is there any way to exclude a directory from being processed.
For example, I want to run a seperate php program in mysite.com/other_app
How can I exclude web/other_app folder from being processed by the symfony controller.
I've tried using
RewriteCond %{REQUEST_URI} !^/other_app/(.*)$
and
RewriteCond %{REQUEST_FILENAME} !-d
Symfony still processes the other_app which obviously isn't going to work properly. Any suggestions.Do I need to modify htaccess in other_app/.htaccess as well?
Also, let me add. When I access just the directory mysite.com/other_app I get the correct content. If I try and access anything below that, I get problems.
This works:
mysite.com/other_app
This does not:
mysite.com/other_app/page1
In the logs I get an error:
Action "other_app/page1" does not exist. Or something similar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的。我想通了。子目录的.htaccess也需要修改。
在 web/.htaccess 中使用:
在子目录中,web/other_app/.htaccess 使用:
这适用于 wordpress 和大多数您想在 symfony 站点上运行但又不想尝试的其他 php 应用程序将其侵入框架。
Ok. I figured it out. The .htaccess of the sub directory also needs to be modified.
In web/.htaccess use:
In the sub directory, web/other_app/.htaccess use:
This will work for wordpress and most any other php app that you want to run on a symfony site, but don't want to deal with trying to hack it into the framework.
尝试添加:
Try adding: