# Specific redirections
if ($args ~* ^redirect_to=\%2fexplore\%2frepos$){ rewrite ^/user/login$ /user/login_redirect_to-_explore_repos? permanent; }
if ($args ~* ^sort=newest&q=&tab=$){ rewrite ^/explore/repos$ /explore/repos_sort-newest-q--tab? permanent; }
if ($args ~* ^sort=oldest&q=&tab=$){ rewrite ^/explore/repos$ /explore/repos_sort-oldest-q--tab? permanent; }
if ($args ~* ^sort=alphabetically&q=&tab=$){ rewrite ^/explore/repos$ /explore/repos_sort-alphabetically-q--tab? permanent; }
if ($args ~* ^sort=reversealphabetically&q=&tab=$){ rewrite ^/explore/repos$ /explore/repos_sort-reversealphabetically-q--tab? permanent; }
if ($args ~* ^sort=recentupdate&q=&tab=$){ rewrite ^/explore/repos$ /explore/repos_sort-recentupdate-q--tab? permanent; }
if ($args ~* ^sort=leastupdate&q=&tab=$){ rewrite ^/explore/repos$ /explore/repos_sort-leastupdate-q--tab? permanent; }
if ($args ~* ^sort=moststars&q=&tab=$){ rewrite ^/explore/repos$ /explore/repos_sort-moststars-q--tab? permanent; }
if ($args ~* ^sort=feweststars&q=&tab=$){ rewrite ^/explore/repos$ /explore/repos_sort-feweststars-q--tab? permanent; }
if ($args ~* ^sort=mostforks&q=&tab=$){ rewrite ^/explore/repos$ /explore/repos_sort-mostforks-q--tab? permanent; }
if ($args ~* ^sort=fewestforks&q=&tab=$){ rewrite ^/explore/repos$ /explore/repos_sort-fewestforks-q--tab? permanent; }
if ($args ~* ^page=2&sort=recentupdate&q=&topic=false$){ rewrite ^/explore/repos$ /explore/repos_page-2-sort-recentupdate-q--topic-false? permanent; }
if ($args ~* ^page=3&sort=recentupdate&q=&topic=false$){ rewrite ^/explore/repos$ /explore/repos_page-3-sort-recentupdate-q--topic-false? permanent; }
if ($args ~* ^page=4&sort=recentupdate&q=&topic=false$){ rewrite ^/explore/repos$ /explore/repos_page-4-sort-recentupdate-q--topic-false? permanent; }
if ($args ~* ^page=5&sort=recentupdate&q=&topic=false$){ rewrite ^/explore/repos$ /explore/repos_page-5-sort-recentupdate-q--topic-false? permanent; }
if ($args ~* ^page=652&sort=recentupdate&q=&topic=false$){ rewrite ^/explore/repos$ /explore/repos_page-652-sort-recentupdate-q--topic-false? permanent; }
if ($args ~* ^redirect_to=\%2fuser\%2fsign_up$){ rewrite ^/user/login$ /user/login_redirect_to-_user_sign_up? 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
