symfony使用index.php进行路由问题

时间:2009-11-04 22:26:07

标签: frameworks symfony1

我有一个用symfony构建的网站。

但是,我正在制定一些路由规则:

resgister:
url:     /register
param:   { module: register, action: index }

我点了一个链接:

link_to('register - here','register')

但此链接指向http://www.mydomain.com/register 而不是http://www.mydomain.com/index.php/register

所以我收到404错误。

此问题仅在生产环境中出现,而不在开发环境中出现。

任何想法?

谢谢!

3 个答案:

答案 0 :(得分:3)

因为no_script_name设置在生产环境中设置为“on”

答案 1 :(得分:3)

YML文件中存在拼写错误:

resgister:
  url:     /register
  param:   { module: register, action: index }

应该是

register:
  url:     /register
  param:   { module: register, action: index }

使用:

echo link_to('register - here','@register');

这应该修复404. no_script_name是你没有看到index.php的原因,如其他几个答案所述。

答案 2 :(得分:0)

您必须在/web/.htaccess文件中取消注释此行RewriteBase /

# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /

这可能会有所帮助:)。

我假设您启用了apache rewrite_module