# invoke rewrite engine
RewriteEngine On
RewriteBase /

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

# Redirect non-www to www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# Specific redirections
RewriteRule ^index\.html$ / [L,R=301]
RewriteCond %{QUERY_STRING} ^month=11&year=2022$
RewriteRule ^calendar$ calendar_month-11-year-2022 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^id=30$
RewriteRule ^calendar_view$ calendar_view_id-30 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^id=34$
RewriteRule ^calendar_view$ calendar_view_id-34 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^id=41$
RewriteRule ^calendar_view$ calendar_view_id-41 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^id=1$
RewriteRule ^page\.php$ page_id-1 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^id=10$
RewriteRule ^page\.php$ page_id-10 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^id=2$
RewriteRule ^page\.php$ page_id-2 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^id=3$
RewriteRule ^page\.php$ page_id-3 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^id=4$
RewriteRule ^page\.php$ page_id-4 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^id=5$
RewriteRule ^page\.php$ page_id-5 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^id=6$
RewriteRule ^page\.php$ page_id-6 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^id=7$
RewriteRule ^page\.php$ page_id-7 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^id=8$
RewriteRule ^page\.php$ page_id-8 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^id=9$
RewriteRule ^page\.php$ page_id-9 [L,R=301,QSD]

# Create pretty URLs
DirectorySlash Off

RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
RewriteRule ^ %1 [NC,L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)/$
RewriteRule ^(.*)/$ $1 [NC,L,R=301]

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]
# 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
