简体   繁体   中英

Symfony2: Redirecting and Favicon?

I've created a registration system like this:

  1. User fills in a form at /register
  2. The form is posted to the same page ( /register )
  3. If the form is valid, the user will be added to the database with 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}
  7. If the token matches to the database, the user will be activated isActive = 1 and redirected to return $this->redirect($this->generateUrl('login')); with a flashmessage Account activated, you can login now.

Everything is working fine, over 1500 users registered in the past 2 days. But some are experiencing trouble activating their account. After clicking the link they receive a 404-error. 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"

/favicon.ico doesn't exist, the favicon is located somewhere else and included in shell.html.twig , so every regular page has the favicon. But because the /activate/{token} is just redirecting, no view is loaded.

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.

Read through this for a start: How to prevent favicon.ico requests?

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.

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. Move to a more recent version of FOS User Bundle and you should be ok.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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