简体   繁体   English

Symfony2路由不匹配

[英]Symfony2 routing no match

We have a symfony2 application. 我们有一个symfony2应用程序。 Everything was successful until we tried to create a subdomain (for a different application). 一切都是成功的,直到我们尝试创建一个子域(用于其他应用程序)为止。 For our first test with the subdomain we linked the subdomain to a route in the s2 application. 对于我们对子域的第一个测试,我们将子域链接到s2应用程序中的路由。

After our test the application always return a 404 code for the route used in the previous test. 在我们测试之后,应用程序总是返回上一个测试中使用的路由的404代码。 We return back all configurations within the server and the problem keeps. 我们返回服务器内的所有配置,问题一直存在。

The route is "/usuario/iniciar-sesion". 路线为“ / usuario / iniciar-sesion”。

Our original configuration for the routing is: 路由的原始配置为:

#/src/AppBundle/Resources/routing.yml
app_user:
    resource: routing/user.yml
    prefix: /usuario

#/src/AppBundle/Resources/routing.yml
app_login:
    path: /iniciar-sesion
    defaults: { _controller: AppBundle:User:login }

We execute the next commands in console to check the routing: 我们在控制台中执行以下命令以检查路由:

php console router:debug
php console router:match /usuario/iniciar-sesion

and everything looks fine. 一切看起来都很好。

Everything else works fine. 其他一切正常。 At this moment the hotfix is changing the prefix (we called "usuarios") and the application runs successful. 此刻,此修补程序正在更改前缀(我们称为“ usuarios”),应用程序运行成功。 After it we tried return back the original prefix, but the application keeps return the 404 code. 之后,我们尝试返回原始前缀,但应用程序继续返回404代码。

We execute a lot of cache:clear --env=prod and manually delete cache dir. 我们执行许多缓存:clear --env = prod并手动删除缓存目录。 In our local enviroment everything works fine. 在我们当地的环境中,一切正常。

What else we can check? 我们还能检查什么?

So as you said in the comment I think you are trying to achieve this: 因此,正如您在评论中所说,我认为您正在尝试实现以下目标:

#/src/AppBundle/Resources/routing.yml
app_login:
    host: usuario.site.com
    path: /iniciar-sesion
    defaults: { _controller: AppBundle:User:login }

And in the server host configuration you need to add the subdomain as a ServerAlias and also own that subdomain I think: https://www.godaddy.com/help/add-a-subdomain-that-points-to-a-server-name-19974 在服务器主机配置中,您需要将子域添加为ServerAlias并拥有该子域,我认为: https : //www.godaddy.com/help/add-a-subdomain-that-points-to-a-server名称-19974

We resolved the problem. 我们解决了这个问题。

We didn't consider the folders created by the server when set up the domain. 设置域时,我们没有考虑服务器创建的文件夹。 We deleted them and the application responds on the original path. 我们删除了它们,应用程序在原始路径上响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM