# invoke rewrite engine
RewriteEngine On
RewriteBase /

Options -Indexes
<IfModule mod_negotiation.c>
	Options -MultiViews
</IfModule>

# Prevent scraping from archive for free demo
RewriteCond %{HTTP_USER_AGENT} (ia_archiver) [NC]
RewriteRule . - [F,L]

# Add a trailing slash (/) to a URL
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.[A-Za-z0-9]*$
RewriteRule .*[^/]$ %{REQUEST_URI}/ [L,R=301]

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

# Create pretty URLs
RewriteRule ^([^/]+)/$ $1.html [S=9]
RewriteRule ^([^/]+)/([^/]+)/$ $1/$2.html [S=8]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3.html [S=7]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4.html [S=6]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4/$5.html [S=5]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4/$5/$6.html [S=4]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4/$5/$6/$7.html [S=3]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4/$5/$6/$7/$8.html [S=2]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4/$5/$6/$7/$8/$9.html [S=1]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4/$5/$6/$7/$8/$9/$10.html
# End: Create pretty URLs

# Redirect all extensions to html
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.shtml$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.phtml$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.jhtml$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.htm$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.php$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.aspx$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.asp$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.jsp$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.apk$ $1.html [L,NC,R=301]
# End: Redirect all extensions to html
