# Redirect non-www to www

# Specific redirections
if ($args ~* ^page=1$){ rewrite ^/news$ /news_page-1? permanent; }
rewrite ^/news/In\sthe\sNews$ /news/IntheNews? permanent;
if ($args ~* ^page=2$){ rewrite ^/news$ /news_page-2? permanent; }
if ($args ~* ^page=1$){ rewrite ^/news/Events$ /news/Events_page-1? permanent; }
if ($args ~* ^page=1$){ rewrite ^/news/In\sthe\sNews$ /news/IntheNews_page-1? permanent; }
if ($args ~* ^path=node/261$){ rewrite ^/forward$ /forward_path-node_261? permanent; }
if ($args ~* ^path=node/258$){ rewrite ^/forward$ /forward_path-node_258? permanent; }
if ($args ~* ^path=node/254$){ rewrite ^/forward$ /forward_path-node_254? permanent; }
rewrite ^/08-09\sCybrary\sWebpages/Cybrary\sK-4\.htm$ /08-09CybraryWebpages/CybraryK-4? permanent;
rewrite ^/08-09\sCybrary\sWebpages/Cybrary\sMain\sPage\.htm$ /08-09CybraryWebpages/CybraryMainPage? permanent;
rewrite ^/08-09\sCybrary\sWebpages/Cybrary\sMiddle\sSchool\s5-8\sPage\.htm$ /08-09CybraryWebpages/CybraryMiddleSchool5-8Page? permanent;
rewrite ^/1st_2nd\sgraders\.htm$ /1st_2ndgraders? permanent;
rewrite ^/7th_8th\sgraders\.htm$ /7th_8thgraders? permanent;
rewrite ^/Ansayweb/Ansay\sWeb\sPage\s%2806%29\.htm$ /Ansayweb/AnsayWebPage(06)? permanent;
if ($args ~* ^tribe-bar-date=2024-09-10$){ rewrite ^/calendar/list$ /calendar/list/tribe-bar-date-2024-09-10? permanent; }
if ($args ~* ^tribe-bar-date=2024-11-26$){ rewrite ^/calendar/list$ /calendar/list/tribe-bar-date-2024-11-26? permanent; }
if ($args ~* ^tribe-bar-date=2024-11-29$){ rewrite ^/calendar/list$ /calendar/list/tribe-bar-date-2024-11-29? permanent; }
if ($args ~* ^tribe-bar-date=2025-02-13$){ rewrite ^/calendar/list$ /calendar/list/tribe-bar-date-2025-02-13? permanent; }
if ($args ~* ^tribe-bar-date=2025-02-14$){ rewrite ^/calendar/list$ /calendar/list/tribe-bar-date-2025-02-14? permanent; }
rewrite ^/code\sof\sconduct\.htm$ /codeofconduct? permanent;
rewrite ^/Cyberschool\sStaff\.htm$ /CyberschoolStaff? permanent;
rewrite ^/cybraryweb/Ready\sRef\s-\sPt2\.html$ /cybraryweb/ReadyRef-Pt2? permanent;
rewrite ^/cybraryweb/teachers\sresources\s-pt3web\.html$ /cybraryweb/teachersresources-pt3web? permanent;
rewrite ^/cybraryweb/web-page\sPt\s-\s5\sengines\.html$ /cybraryweb/web-pagePt-5engines? permanent;
rewrite ^/cybraryweb/web-page\sPt-\s4\sency\.html$ /cybraryweb/web-pagePt-4ency? permanent;
rewrite ^/cybraryweb/web-page\sPt-6\snews\.html$ /cybraryweb/web-pagePt-6news? permanent;
rewrite ^/employment\sopportunities\.htm$ /employmentopportunities? permanent;
if ($args ~* ^path=node/176$){ rewrite ^/forward$ /forward_path-node_176? permanent; }
if ($args ~* ^path=node/252$){ rewrite ^/forward$ /forward_path-node_252? permanent; }
if ($args ~* ^path=node/253$){ rewrite ^/forward$ /forward_path-node_253? permanent; }
rewrite ^/mission\sand\svision\.htm$ /missionandvision? permanent;
rewrite ^/parent\sinformation\sfolder/bullyindex\.htm$ /parentinformationfolder/bullyindex? permanent;
rewrite ^/parent\sinformation\sfolder/c3lp\.html$ /parentinformationfolder/c3lp? permanent;
rewrite ^/parent\sinformation\.htm$ /parentinformation? permanent;
rewrite ^/Parent\sInformation\.html$ /ParentInformation? permanent;
rewrite ^/rossweb/book\sprojects\.html$ /rossweb/bookprojects? permanent;
rewrite ^/rossweb/Watson's\.html$ /rossweb/Watson-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
