# Redirect non-www to www

# Specific redirections
if($is_args = ''){ rewrite ^/index\.php$ /index_php? permanent; }
rewrite ^/index\.php/fabrica/missao$ /index_php/fabrica/missao? permanent;
rewrite ^/index\.php/fabrica/produtos$ /index_php/fabrica/produtos? permanent;
rewrite ^/index\.php/fabrica/internacional$ /index_php/fabrica/internacional? permanent;
rewrite ^/index\.php/fabrica/informacoes$ /index_php/fabrica/informacoes? permanent;
rewrite ^/index\.php/fabrica/informacoes/alergeneos$ /index_php/fabrica/informacoes/alergeneos? permanent;
rewrite ^/index\.php/fabrica/informacoes/litigios-consumo$ /index_php/fabrica/informacoes/litigios-consumo? permanent;
rewrite ^/index\.php/fabrica/informacoes/reg-boas-practicas$ /index_php/fabrica/informacoes/reg-boas-practicas? permanent;
rewrite ^/index\.php/empresa$ /index_php/empresa? permanent;
rewrite ^/index\.php/login$ /index_php/login? permanent;
if ($args ~* ^view=reset$){ rewrite ^/index\.php/login$ /index_php/login_view-reset? permanent; }
if ($args ~* ^view=remind$){ rewrite ^/index\.php/login$ /index_php/login_view-remind? permanent; }
rewrite ^/index\.php/component/finder/search$ /index_php/component/finder/search? permanent;
if ($args ~* ^tmpl=component$){ rewrite ^/index\.php/fabrica/missao$ /index_php/fabrica/missao_tmpl-component? permanent; }
if ($args ~* ^tmpl=component&template=rt_anacron&link=7ee4d2a99d483b68d8b4b3af6902795e746bd7f9$){ rewrite ^/index\.php/component/mailto$ /index_php/component/mailto/tmpl-component-template-rt_anacron-link-7ee4d2a99d483b68d8b4b3af6902795e746bd7f9? permanent; }
if ($args ~* ^start=5$){ rewrite ^/index\.php/fabrica/produtos$ /index_php/fabrica/produtos_start-5? permanent; }
if ($args ~* ^start=10$){ rewrite ^/index\.php/fabrica/produtos$ /index_php/fabrica/produtos_start-10? 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
