# Redirect non-www to www

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