# Redirect non-www to www

# Specific redirections
if ($args ~* ^next=fr$){ rewrite ^/fr/log-in$ /fr/log-in_next-fr? permanent; }
if ($args ~* ^next=fr$){ rewrite ^/fr/sing-up$ /fr/sing-up_next-fr? permanent; }
if ($args ~* ^next=fr/my-orders$){ rewrite ^/fr/log-in$ /fr/log-in_next-fr_my-orders? permanent; }
if ($args ~* ^next=fr/comments$){ rewrite ^/fr/log-in$ /fr/log-in_next-fr_comments? permanent; }
if ($args ~* ^next=fr/home$){ rewrite ^/fr/log-in$ /fr/log-in_next-fr_home? permanent; }
if ($args ~* ^next=fr/home$){ rewrite ^/fr/sing-up$ /fr/sing-up_next-fr_home? permanent; }
if ($args ~* ^next=fr/comments$){ rewrite ^/fr/sing-up$ /fr/sing-up_next-fr_comments? permanent; }
if ($args ~* ^next=fr/log-in$){ rewrite ^/fr/log-in$ /fr/log-in-next-fr/log-in_next? permanent; }
if ($args ~* ^next=fr/log-in$){ rewrite ^/fr/sing-up$ /fr/sing-up-next-fr/log-in_next? permanent; }
if ($args ~* ^step=&next=fr$){ rewrite ^/fr/sing-up$ /fr/sing-up_step--next-fr? permanent; }
if ($args ~* ^step=&next=fr$){ rewrite ^/login\.php$ /login_step--next-fr? 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
