# Add a trailing slash (/) to a URL
rewrite ^([^.]*[^/])$ $1/ permanent;

# Specific redirections
if ($args ~* ^s=$){ rewrite ^//?$ /s/? permanent; }
if ($args ~* ^s=$){ rewrite ^/about/?$ /about/s/? permanent; }
if ($args ~* ^s=$){ rewrite ^/ctag-representatives/?$ /ctag-representatives/s/? permanent; }
if ($args ~* ^s=$){ rewrite ^/ct-contacts/?$ /ct-contacts/s/? permanent; }
if ($args ~* ^s=$){ rewrite ^/current-issues/?$ /current-issues/s/? permanent; }
if ($args ~* ^s=$){ rewrite ^/minutes/?$ /minutes/s/? permanent; }
if ($args ~* ^s=$){ rewrite ^/2021-ctag-member-solicitation/?$ /2021-ctag-member-solicitation/s/? permanent; }
if ($args ~* ^s=$){ rewrite ^/author/admin/?$ /author/admin/s/? permanent; }
if ($args ~* ^s=$){ rewrite ^/category/addressed-by-revised-40-cfr-part-171/?$ /category/addressed-by-revised-40-cfr-part-171/s/? permanent; }
if ($args ~* ^s=$){ rewrite ^/category/category/supervision/?$ /category/category/supervision/s/? permanent; }
if ($args ~* ^s=$){ rewrite ^/category/resource/paper/?$ /category/resource/paper/s/? permanent; }
if ($args ~* ^s=$){ rewrite ^/category/resource/survey/?$ /category/resource/survey/s/? permanent; }
if ($args ~* ^s=$){ rewrite ^/category/year/2009/?$ /category/year/2009/s/? permanent; }
if ($args ~* ^s=$){ rewrite ^/category/year/2013/?$ /category/year/2013/s/? permanent; }
if ($args ~* ^s=$){ rewrite ^/continuing-competency-workgroup-survey/?$ /continuing-competency-workgroup-survey/s/? permanent; }
if ($args ~* ^s=$){ rewrite ^/documents/?$ /documents/s/? permanent; }
if ($args ~* ^s=$){ rewrite ^/recertification-online-training-course-design-structure/?$ /recertification-online-training-course-design-structure/s/? 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
