# 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} ^query=Inlays\%26Onlays$
RewriteRule ^education\.html$ education_query-Inlays-Onlays [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^query=Impacted\+Wisdom\+Teeth$
RewriteRule ^education\.html$ education_query-Impacted-Wisdom-Teeth [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^query=Your\+Rightsasa\+Patient$
RewriteRule ^education\.html$ education_query-Your-Rightsasa-Patient [L,R=301,QSD]
RewriteRule ^library/72/Chipped%2CCracked%2CandWornTeeth\.html$ library/72/Chipped-Cracked-andWornTeeth [L,R=301,QSD]
RewriteRule ^library/7658/Aging%26DentalHealth\.html$ library/7658/Aging-DentalHealth [L,R=301,QSD]
RewriteRule ^library/7664/BloodPressureMedications%26YourGums\.html$ library/7664/BloodPressureMedications-YourGums [L,R=301,QSD]
RewriteRule ^library/7669/Brushing%26FlossingwithBraces\.html$ library/7669/Brushing-FlossingwithBraces [L,R=301,QSD]
RewriteRule ^library/7671/CombinedRootCanal%26GumProblems\.html$ library/7671/CombinedRootCanal-GumProblems [L,R=301,QSD]
RewriteRule ^library/7682/Diabetes%26OralHealth\.html$ library/7682/Diabetes-OralHealth [L,R=301,QSD]
RewriteRule ^library/7686/EatingDisorders%26OralHealth\.html$ library/7686/EatingDisorders-OralHealth [L,R=301,QSD]
RewriteRule ^library/7691/Fluoride%26YourChild\.html$ library/7691/Fluoride-YourChild [L,R=301,QSD]
RewriteRule ^library/7699/Headaches%26Migraines\.html$ library/7699/Headaches-Migraines [L,R=301,QSD]
RewriteRule ^library/7711/LooseTeeth%26BiteProblems\.html$ library/7711/LooseTeeth-BiteProblems [L,R=301,QSD]
RewriteRule ^library/7715/Nutrition%26OralHealth\.html$ library/7715/Nutrition-OralHealth [L,R=301,QSD]
RewriteRule ^library/7727/Orthodontics%26DentalHygiene\.html$ library/7727/Orthodontics-DentalHygiene [L,R=301,QSD]
RewriteRule ^library/7728/Osteoporosis%26OralHealth\.html$ library/7728/Osteoporosis-OralHealth [L,R=301,QSD]
RewriteRule ^library/7737/Pregnancy%26YourChild%27sDevelopingTeeth\.html$ library/7737/Pregnancy-YourChild-sDevelopingTeeth [L,R=301,QSD]
RewriteRule ^library/7738/Pregnancy%2CHormones%26OralHealth\.html$ library/7738/Pregnancy-Hormones-OralHealth [L,R=301,QSD]
RewriteRule ^library/7751/Snoring%26SleepApnea\.html$ library/7751/Snoring-SleepApnea [L,R=301,QSD]
RewriteRule ^library/7753/Stress%26OralHabits\.html$ library/7753/Stress-OralHabits [L,R=301,QSD]
RewriteRule ^library/7763/ToothContouring%26Reshaping\.html$ library/7763/ToothContouring-Reshaping [L,R=301,QSD]
RewriteRule ^library/7779/Cosmetic%26GeneralDentistry\.html$ library/7779/Cosmetic-GeneralDentistry [L,R=301,QSD]
RewriteRule ^library/7781/Inlays%26Onlays\.html$ library/7781/Inlays-Onlays [L,R=301,QSD]
RewriteRule ^library/7823/Crowns%26Bridgework\.html$ library/7823/Crowns-Bridgework [L,R=301,QSD]
RewriteRule ^library/8054/BloodThinners%26DentalProcedures\.html$ library/8054/BloodThinners-DentalProcedures [L,R=301,QSD]
RewriteRule ^library/8387/CleftLip%26PalateRepair\.html$ library/8387/CleftLip-PalateRepair [L,R=301,QSD]
RewriteRule ^library/8392/Thumb%26FingerAppliances\.html$ library/8392/Thumb-FingerAppliances [L,R=301,QSD]
RewriteRule ^library/8396/SleepApnea%26BehaviorProblemsinChildren\.html$ library/8396/SleepApnea-BehaviorProblemsinChildren [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
