# Specific redirections
if ($args ~* ^view=minimal$){ rewrite ^/debates$ /debates_view-minimal? permanent; }
if ($args ~* ^order=hot_score&page=1$){ rewrite ^/debates$ /debates_order-hot_score-page-1? permanent; }
if ($args ~* ^order=confidence_score&page=1$){ rewrite ^/debates$ /debates_order-confidence_score-page-1? permanent; }
if ($args ~* ^order=created_at&page=1$){ rewrite ^/debates$ /debates_order-created_at-page-1? permanent; }
if ($args ~* ^search=EDUCACION\+-\+GR\+Educaci\%C3\%B3n$){ rewrite ^/debates$ /debates_search-EDUCACION---GR-Educación? permanent; }
if ($args ~* ^search=SALUD\+-\+GR\+Salud$){ rewrite ^/debates$ /debates_search-SALUD---GR-Salud? permanent; }
if ($args ~* ^search=AMBIENTE\+-\+GR\+Ambiente$){ rewrite ^/debates$ /debates_search-AMBIENTE---GR-Ambiente? permanent; }
if ($args ~* ^search=VIVIENDA\+Y\+SANEAMIENTO\+-\+GR\+Vivienda$){ rewrite ^/debates$ /debates_search-VIVIENDA-Y-SANEAMIENTO---GR-Vivienda? permanent; }
if ($args ~* ^search=CULTURA\+-\+GR\+Educaci\%C3\%B3n$){ rewrite ^/debates$ /debates_search-CULTURA---GR-Educación? permanent; }
if ($args ~* ^search=TURISMO\+-\+GR\+Comercio\+Exterior\+y\+Turismo$){ rewrite ^/debates$ /debates_search-TURISMO---GR-Comercio-Exterior-y-Turismo? permanent; }
if ($args ~* ^search=ARTESAN\%C3\%8DA\+-\+GR\+Comercio\+Exterior\+y\+T\.$){ rewrite ^/debates$ /debates_search-ARTESANÍA---GR-Comercio-Exterior-y-T_? permanent; }
if ($args ~* ^search=AGRICULTURA\+-\+GR\+Agricultura$){ rewrite ^/debates$ /debates_search-AGRICULTURA---GR-Agricultura? permanent; }
if ($args ~* ^search=SEGURIDAD\+CIUDADANA\+-\+CR\+Defensa\+Nac\.$){ rewrite ^/debates$ /debates_search-SEGURIDAD-CIUDADANA---CR-Defensa-Nac_? permanent; }
if ($args ~* ^search=DEFENSA\+CIVIL\+-\+CR\+Defensa\+Nacional$){ rewrite ^/debates$ /debates_search-DEFENSA-CIVIL---CR-Defensa-Nacional? permanent; }
if ($args ~* ^search=CULTURA\+-$){ rewrite ^/debates$ /debates_search-CULTURA--? permanent; }
if ($args ~* ^search=SEGURIDAD\+CUIDADANA$){ rewrite ^/debates$ /debates_search-SEGURIDAD-CUIDADANA? permanent; }
if ($args ~* ^search=TRANSPORTES\+-\+GR\+Transportes$){ rewrite ^/debates$ /debates_search-TRANSPORTES---GR-Transportes? permanent; }
if ($args ~* ^search=COMUNICACIONES\+-\+GR\+Transportes$){ rewrite ^/debates$ /debates_search-COMUNICACIONES---GR-Transportes? permanent; }
if ($args ~* ^search=TRABAJO\+Y\+PROMOCI\%C3\%93N\+EMPLEO\+-\+GR\+Trabajo$){ rewrite ^/debates$ /debates_search-TRABAJO-Y-PROMOCIÓN-EMPLEO---GR-Trabajo? permanent; }
if ($args ~* ^search=MICROEMPRESA\+-\+GR\+Producci\%C3\%B3n$){ rewrite ^/debates$ /debates_search-MICROEMPRESA---GR-Producción? permanent; }
if ($args ~* ^search=INDUSTRIA\+-\+GR\+Produccion$){ rewrite ^/debates$ /debates_search-INDUSTRIA---GR-Produccion? permanent; }
if ($args ~* ^search=\%23TrabajoInfantil$){ rewrite ^/debates$ /debates_search? permanent; }
if ($args ~* ^page=2$){ rewrite ^/debates$ /debates_page-2? permanent; }
if ($args ~* ^page=1$){ rewrite ^/debates$ /debates_page-1? permanent; }

# Create pretty URLs
rewrite ^/([^/]+)$ /$1.html last;
rewrite ^/([^/]+)/([^/]+)$ /$1/$2.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)$ /$1/$2/$3.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /$1/$2/$3/$4.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /$1/$2/$3/$4/$5.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /$1/$2/$3/$4/$5/$6.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /$1/$2/$3/$4/$5/$6/$7.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /$1/$2/$3/$4/$5/$6/$7/$8.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /$1/$2/$3/$4/$5/$6/$7/$8/$9.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /$1/$2/$3/$4/$5/$6/$7/$8/$9/$10.html last;
# End: Create pretty URLs

# Redirect all extensions to html
if ($is_args = ''){
	rewrite ^([^.]*)\.shtml$ $1.html permanent;
	rewrite ^([^.]*)\.phtml$ $1.html permanent;
	rewrite ^([^.]*)\.jhtml$ $1.html permanent;
	rewrite ^([^.]*)\.htm$ $1.html permanent;
	rewrite ^([^.]*)\.php$ $1.html permanent;
	rewrite ^([^.]*)\.aspx$ $1.html permanent;
	rewrite ^([^.]*)\.asp$ $1.html permanent;
	rewrite ^([^.]*)\.jsp$ $1.html permanent;
	rewrite ^([^.]*)\.apk$ $1.html permanent;
}
# End: Redirect all extensions to html
