# 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]

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

# Specific redirections
RewriteRule ^index\.html$ / [L,R=301]
RewriteCond %{QUERY_STRING} ^&max-results=20$
RewriteRule ^search/label/food$ search/label/food_-max-results-20 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^&max-results=20$
RewriteRule ^search/label/buying\sa\shome$ search/label/buyingahome_-max-results-20 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^&max-results=20$
RewriteRule ^search/label/finances$ search/label/finances_-max-results-20 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^&max-results=20$
RewriteRule ^search/label/home$ search/label/home_-max-results-20 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^&max-results=20$
RewriteRule ^search/label/money$ search/label/money_-max-results-20 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^&max-results=20$
RewriteRule ^search/label/My\sSunday\sPhoto$ search/label/MySundayPhoto_-max-results-20 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^&max-results=20$
RewriteRule ^search/label/pregnancy$ search/label/pregnancy_-max-results-20 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^&max-results=20$
RewriteRule ^search/label/beach$ search/label/beach_-max-results-20 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^&max-results=20$
RewriteRule ^search/label/days\sout$ search/label/daysout_-max-results-20 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^&max-results=20$
RewriteRule ^search/label/family$ search/label/family_-max-results-20 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^updated-max=2017-09-28T01\:08\:00\%2B01\:00&max-results=5$
RewriteRule ^search$ search_updated-max-2017-09-28T01-08-00-01-00-max-results-5 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^&max-results=20$
RewriteRule ^search/label/Me\sand\sMine$ search/label/MeandMine_-max-results-20 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^&max-results=20$
RewriteRule ^search/label/siblings$ search/label/siblings_-max-results-20 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^&max-results=20$
RewriteRule ^search/label/family\sadventures$ search/label/familyadventures_-max-results-20 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^&max-results=20_blank$
RewriteRule ^search/label/pregnancy$ search/label/pregnancy_-max-results-20_blank [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^q=pregnancy$
RewriteRule ^search$ search_q-pregnancy [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
