Symfony 在线项目路由问题
我在 Win XP / IIS 7 机器上有一个 Symfony 项目,安装了 Isapi rewrite。当我进入前端(我的主)应用程序时,路由似乎根本不起作用。我总是以我的默认模块/操作结束。但是,如果我关闭no_script_name = off
(在应用程序的settings.yml 文件中),那么一切都会正常工作。我还有一个管理应用程序作为项目的一部分(其中也有 no_script_name = off
),并且效果也很好。这看起来应该是一个简单的问题,但我们已经为此工作了 4 个小时。任何帮助将不胜感激,谢谢。
编辑:我将前端控制器的环境更改为 dev 以便使用调试工具栏,发现无论我的 URL 是什么样子,它总是显示
Match route "homepage" (/) for / withparameters array ( 'module' => ; 'default', 'action' =>,)
无论我做什么,模块总是等于默认值
I have a Symfony project on a Win XP / IIS 7 machine with Isapi rewrite installed. When I go to the frontend (my main) application, it seems that the routing simply doesn't work. I always end up on my default module/action. However, if I turnno_script_name = off
(in the app's settings.yml file) then everything works fine. I also have an admin app as part of the project (which also has no_script_name = off
) and this works fine as well. This seems like it should be a simple problem, yet we've been working on this for 4 hours now. Any help would be greatly appreciated, thanks.
Edit: I changed the front controller's environment to dev in order to use the debug toolbar and found that no matter what my URL looks like, it always says
Match route "homepage" (/) for / with parameters array ( 'module' => 'default', 'action' => 'index',)
No matter what I do, module always equals default
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
IIS 不太支持 URL 重写,而这是 Symfony 路由工作的要求。本质上,网络服务器应该将所有对不存在文件/路径的请求重定向到 Symfony 的 index.php,并传递请求的原始 URL。 Symfony 解码此 URL 并应用其路由规则。
但是,这是可能的。您需要遵循以下步骤:IIS 上的 Symfony
IIS doesn't support URL rewriting very well, which is a requirement of Symfony's routing to work. Essentially, the webserver is supposed to redirect all requests to non-existing files/paths to Symfony's index.php, passing along with it the original URL requested. Symfony decodes this URL and applies its routing rules.
But, it's possible. You'll need to follow this: Symfony on IIS
我找到了解决方案。我将此代码添加到我的index.php的顶部
我尝试了Symfony on IIS教程中的所有内容( http://trac.symfony-project.org/wiki/symfonyOnIIS)并没有什么区别。如果其他人遇到此问题,请先尝试添加上述代码,然后再使用任何设置或 .htaccess 规则。
I've found the solution. I added this code to the top of my index.php
I tried everything within the Symfony on IIS tutorial (http://trac.symfony-project.org/wiki/symfonyOnIIS) and nothing made a difference. If anyone else runs into this problem, please try adding the above code first before mucking with any settings or .htaccess rules.
查看 IIS 的新 URL 重写模块:
http://learn .iis.net/page.aspx/734/url-rewrite-module/
它甚至向 IIS 管理器添加了一个工具,用于导入和转换 mod_rewrite 规则
Check out the new Url Rewrite module for IIS:
http://learn.iis.net/page.aspx/734/url-rewrite-module/
It even adds a tool to IIS manager which imports and converts mod_rewrite rules