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

# Specific redirections
if ($args ~* ^page_id=820$){ rewrite ^//?$ /page_id-820/? permanent; }
rewrite ^/calendar/action~oneday/exact_date~9-7-2017$ /calendar/action-oneday/exact_date-9-7-2017/? permanent;
if ($args ~* ^instance_id=11302$){ rewrite ^/event/prayer-calendar-perry-clayton-kenneth-clayton-marvin-saylors/?$ /event/prayer-calendar-perry-clayton-kenneth-clayton-marvin-saylors/instance_id-11302/? permanent; }
rewrite ^/calendar/action~oneday/exact_date~10-7-2017$ /calendar/action-oneday/exact_date-10-7-2017/? permanent;
if ($args ~* ^instance_id=7316$){ rewrite ^/event/prayer-calendar-gerald-taylor-royce-martin-chris-sparkman/?$ /event/prayer-calendar-gerald-taylor-royce-martin-chris-sparkman/instance_id-7316/? permanent; }
rewrite ^/calendar/action~oneday/exact_date~11-7-2017$ /calendar/action-oneday/exact_date-11-7-2017/? permanent;
if ($args ~* ^instance_id=10056$){ rewrite ^/event/prayer-calendar-jim-rogers-danny-whitson-chris-reagan/?$ /event/prayer-calendar-jim-rogers-danny-whitson-chris-reagan/instance_id-10056/? permanent; }
rewrite ^/calendar/action~oneday/exact_date~12-7-2017$ /calendar/action-oneday/exact_date-12-7-2017/? permanent;
if ($args ~* ^instance_id=8854$){ rewrite ^/event/prayer-calendar-billy-cowan-louis-davis-micah-dunford/?$ /event/prayer-calendar-billy-cowan-louis-davis-micah-dunford/instance_id-8854/? permanent; }
rewrite ^/calendar/action~oneday/exact_date~13-7-2017$ /calendar/action-oneday/exact_date-13-7-2017/? permanent;
if ($args ~* ^instance_id=9925$){ rewrite ^/event/prayer-calendar-james-staley-willie-cameron-jerry-myers/?$ /event/prayer-calendar-james-staley-willie-cameron-jerry-myers/instance_id-9925/? permanent; }
if ($args ~* ^plugin=all-in-one-event-calendar&controller=ai1ec_exporter_controller&action=export_events$){ rewrite ^//?$ /plugin-all-in-one-event-calendar-controller-ai1ec_exporter_controller-action-export_events/? permanent; }
if ($args ~* ^plugin=all-in-one-event-calendar&controller=ai1ec_exporter_controller&action=export_events&no_html=true$){ rewrite ^//?$ /plugin-all-in-one-event-calendar-controller-ai1ec_exporter_controller-action-export_events-no_html-true/? permanent; }
if ($args ~* ^plugin=all-in-one-event-calendar&controller=ai1ec_exporter_controller&action=export_events&xml=true$){ rewrite ^//?$ /plugin-all-in-one-event-calendar-controller-ai1ec_exporter_controller-action-export_events-xml-true/? permanent; }
rewrite ^/calendar/action~agenda/request_format~html$ /calendar/action-agenda/request_format-html/? permanent;
rewrite ^/calendar/action~oneday/request_format~html$ /calendar/action-oneday/request_format-html/? permanent;
rewrite ^/calendar/action~month/request_format~html$ /calendar/action-month/request_format-html/? permanent;
rewrite ^/calendar/action~week/request_format~html$ /calendar/action-week/request_format-html/? permanent;
rewrite ^/calendar/action~agenda/page_offset~-1/request_format~html$ /calendar/action-agenda/page_offset--1/request_format-html/? permanent;
rewrite ^/calendar/action~agenda/page_offset~1/request_format~html$ /calendar/action-agenda/page_offset-1/request_format-html/? permanent;
rewrite ^/calendar/action~oneday/exact_date~16-11-2016$ /calendar/action-oneday/exact_date-16-11-2016/? permanent;
if ($args ~* ^instance_id=9641$){ rewrite ^/event/prayer-calendar-jeff-cotterman-david-neal-john-murphy/?$ /event/prayer-calendar-jeff-cotterman-david-neal-john-murphy/instance_id-9641/? permanent; }
rewrite ^/calendar/action~oneday/exact_date~17-11-2016$ /calendar/action-oneday/exact_date-17-11-2016/? permanent;
if ($args ~* ^instance_id=8438$){ rewrite ^/event/prayer-calendar-jeff-burton-wallace-caldwell-tim-dunavant/?$ /event/prayer-calendar-jeff-burton-wallace-caldwell-tim-dunavant/instance_id-8438/? permanent; }
rewrite ^/calendar/action~oneday/exact_date~18-11-2016$ /calendar/action-oneday/exact_date-18-11-2016/? permanent;
if ($args ~* ^instance_id=1963$){ rewrite ^/event/ministry-academy/?$ /event/ministry-academy/instance_id-1963/? permanent; }
if ($args ~* ^instance_id=6229$){ rewrite ^/event/prayer-calendar-jay-archer-moses-han-james-bryant-2/?$ /event/prayer-calendar-jay-archer-moses-han-james-bryant-2/instance_id-6229/? permanent; }
rewrite ^/calendar/action~oneday/exact_date~19-11-2016$ /calendar/action-oneday/exact_date-19-11-2016/? permanent;
if ($args ~* ^instance_id=5420$){ rewrite ^/event/prayer-calendar-carl-stiglich-caroline-sanders-floyd-massey/?$ /event/prayer-calendar-carl-stiglich-caroline-sanders-floyd-massey/instance_id-5420/? permanent; }
rewrite ^/calendar/action~oneday/exact_date~20-11-2016$ /calendar/action-oneday/exact_date-20-11-2016/? permanent;
if ($args ~* ^instance_id=8291$){ rewrite ^/event/prayer-calendar-joseph-johnson-ron-smith-jim-gruber/?$ /event/prayer-calendar-joseph-johnson-ron-smith-jim-gruber/instance_id-8291/? permanent; }
if ($args ~* ^instance_id=3523$){ rewrite ^/event/bon-air-cc/?$ /event/bon-air-cc/instance_id-3523/? permanent; }
if ($args ~* ^instance_id=7718$){ rewrite ^/event/claysville-cc/?$ /event/claysville-cc/instance_id-7718/? permanent; }
if ($args ~* ^instance_id=6484$){ rewrite ^/event/pomona-cc/?$ /event/pomona-cc/instance_id-6484/? permanent; }
if ($args ~* ^instance_id=9770$){ rewrite ^/event/tolletts-woodlawn-cc/?$ /event/tolletts-woodlawn-cc/instance_id-9770/? permanent; }
rewrite ^/calendar/action~oneday/exact_date~15-10-2016$ /calendar/action-oneday/exact_date-15-10-2016/? permanent;
if ($args ~* ^instance_id=9378$){ rewrite ^/event/prayer-calendar-ricky-lee-gerald-harlan-mary-foote/?$ /event/prayer-calendar-ricky-lee-gerald-harlan-mary-foote/instance_id-9378/? permanent; }
if ($args ~* ^instance_id=9367$){ rewrite ^/event/umw-annual-meeting/?$ /event/umw-annual-meeting/instance_id-9367/? permanent; }
rewrite ^/calendar/action~oneday/exact_date~16-10-2016$ /calendar/action-oneday/exact_date-16-10-2016/? permanent;
if ($args ~* ^instance_id=9785$){ rewrite ^/event/prayer-calendar-tom-chandler-susan-lupo-kathy-grisham/?$ /event/prayer-calendar-tom-chandler-susan-lupo-kathy-grisham/instance_id-9785/? permanent; }
if ($args ~* ^instance_id=7997$){ rewrite ^/event/pleasant-grove-cc/?$ /event/pleasant-grove-cc/instance_id-7997/? permanent; }
if ($args ~* ^instance_id=8572$){ rewrite ^/event/chestnut-mound-cc/?$ /event/chestnut-mound-cc/instance_id-8572/? permanent; }
rewrite ^/calendar/action~oneday/exact_date~13-10-2016$ /calendar/action-oneday/exact_date-13-10-2016/? permanent;
if ($args ~* ^instance_id=7045$){ rewrite ^/event/prayer-calendar-phil-and-luanna-tollett-kathy-bowles-john-vaughan/?$ /event/prayer-calendar-phil-and-luanna-tollett-kathy-bowles-john-vaughan/instance_id-7045/? permanent; }
if ($args ~* ^instance_id=7439$){ rewrite ^/event/hickory-valley-cc/?$ /event/hickory-valley-cc/instance_id-7439/? permanent; }
if ($args ~* ^instance_id=2124$){ rewrite ^/event/burtons-kynett-wrights-cc/?$ /event/burtons-kynett-wrights-cc/instance_id-2124/? permanent; }
rewrite ^/calendar/action~oneday/exact_date~14-10-2016$ /calendar/action-oneday/exact_date-14-10-2016/? permanent;
if ($args ~* ^instance_id=6633$){ rewrite ^/event/prayer-calendar-josh-newberry-don-spencer-dickie-johnson/?$ /event/prayer-calendar-josh-newberry-don-spencer-dickie-johnson/instance_id-6633/? 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
