简体   繁体   English

Symfony2:重定向和Favicon?

[英]Symfony2: Redirecting and Favicon?

I've created a registration system like this: 我创建了这样的注册系统:

  1. User fills in a form at /register 用户在/register处填写表格
  2. The form is posted to the same page ( /register ) 表单被发布到同一页面( /register
  3. If the form is valid, the user will be added to the database with isActive = 0 如果表单有效,则用户将被添加到isActive = 0的数据库中
  4. A token will be generated to activate the user 将生成一个令牌来激活用户
  5. The user gets an e-mail with a link containing the token 用户收到一封电子邮件,其中包含包含令牌的链接
  6. The user clicks the link and goes to /activate/{token} 用户单击链接并转到/activate/{token}
  7. If the token matches to the database, the user will be activated isActive = 1 and redirected to return $this->redirect($this->generateUrl('login')); 如果令牌与数据库匹配,则将激活isActive = 1并重定向用户以return $this->redirect($this->generateUrl('login')); with a flashmessage Account activated, you can login now. Account activated, you can login now.了flashmessage Account activated, you can login now.

Everything is working fine, over 1500 users registered in the past 2 days. 一切正常,在过去2天中注册了1500多名用户。 But some are experiencing trouble activating their account. 但是有些人在激活其帐户时遇到麻烦。 After clicking the link they receive a 404-error. 单击链接后,他们将收到404错误。 However, their accounts are activated as supposed. 但是,他们的帐户已按预期方式激活。

I searched the logs and found around 1500 records, more or less around the time users are activating their account: No route found for "GET /favicon.ico" 我搜索了日志,发现大约有1500条记录,大约在用户激活帐户时: No route found for "GET /favicon.ico"

/favicon.ico doesn't exist, the favicon is located somewhere else and included in shell.html.twig , so every regular page has the favicon. /favicon.ico不存在,该图标集位于其他位置,并且包含在shell.html.twig ,因此每个常规页面都具有该图标集。 But because the /activate/{token} is just redirecting, no view is loaded. 但是由于/activate/{token}仅在重定向,因此不会加载任何视图。

It possible this has something to do with the error some users are encoutering? 这可能与某些用户令人陶醉的错误有关吗?

Maybe the error has nothing to do with the favicon, all suggestion are more then welcome. 也许错误与网站图标无关,所有建议都值得欢迎。 I'm not able to reproduce the error, so it's very hard to debug at the moment. 我无法重现该错误,因此目前很难调试。

Also try to use different browsers to test this. 也请尝试使用其他浏览器进行测试。 You can also test this on your local machine. 您也可以在本地计算机上对此进行测试。 I have found online that some browsers (IE) automatically request /favicon.ico in some cases, if you include it somewhere or not. 我在网上发现,某些浏览器(IE)在某些情况下会自动请求/favicon.ico,如果您将其包含在某处或不在某处。

Read through this for a start: How to prevent favicon.ico requests? 通读这篇文章作为起点: 如何防止favicon.ico请求?

I see this is an old thread and you probably solved your issue years ago but here are my two cents - when I try to run a Symfony 2.3 application with one of the later php 5 versions, I get the same error message as you in my log file, it complains about the favicon. 我看到这是一个旧线程,您可能在几年前就解决了您的问题,但是这是我的两分钱-当我尝试使用更高版本的php 5版本运行Symfony 2.3应用程序时,我收到与您相同的错误消息日志文件,它抱怨该图标。

That is however not the real issue. 但是,这不是真正的问题。 The real issue that caused this redirection and in turn the favicon-issue is that I am using an old version of FOS User Bundle, and there is a conflict between the user unserialization and the new php version. 引起此重定向并进而导致favicon问题的真正问题是,我使用的是FOS用户捆绑包的旧版本,并且用户反序列化和新的php版本之间存在冲突。 Move to a more recent version of FOS User Bundle and you should be ok. 移至FOS User Bundle的最新版本,您应该没问题。

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

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