We used Prerender.io for performance SEO in Angular JSf. But we had a problem with Facebook because they save url link with escaped_fragment so when you navigate with a browser some “Angular things” don’t work.

The solution: we only need to do two conditions:

IF url has include escaped_fragment


you are in a browse


redirect to hashbang.

This is the code:

set $redirect "";

if ($http_user_agent ~* '(Mozilla)') {
  set $redirect  G;

if ($arg__escaped_fragment_) {
  set $redirect  "${redirect}O";

if ($redirect = GO) {
  rewrite ^ $scheme://$host/#!$arg__escaped_fragment_? break;

It’s very funny how you have to do an AND condition in Nginx :-)