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

    RewriteEngine On

    # -----------------------------------
    # 1. FORCE HTTPS + REMOVE WWW
    # -----------------------------------
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC,OR]
    RewriteCond %{HTTPS} off
    RewriteRule ^ https://chaggerdental.com%{REQUEST_URI} [L,R=301]

    # -----------------------------------
    # 2. SIMPLE SAFE REDIRECTS
    # -----------------------------------
    Redirect 301 /about-us https://chaggerdental.com/about
    Redirect 301 /book-an-appointment https://chaggerdental.com/book-appointment
    Redirect 301 /contact-us https://chaggerdental.com/book-appointment
    Redirect 301 /gallery/flower-garden https://chaggerdental.com
    Redirect 301 /gallery https://chaggerdental.com
    Redirect 301 /locations/dentist-burlington-on https://chaggerdental.com/location/burlington
    Redirect 301 /locations/dentist-mississauga-on https://chaggerdental.com/location/mississauga
    Redirect 301 /locations/dentist-oak-park-oakville-on https://chaggerdental.com/location/oakville
    Redirect 301 /oakville-location.html https://chaggerdental.com/location/oakville
    Redirect 301 /privacy-policy https://chaggerdental.com
    Redirect 301 /services/bonding https://chaggerdental.com/service/bonding
    Redirect 301 /services/cerec-3d https://chaggerdental.com/service/cerec-crowns
    Redirect 301 /services/cosmetic-dentistry https://chaggerdental.com/service/cosmetic-dentistry
    Redirect 301 /services/dental-crowns https://chaggerdental.com/service/dental-crowns
    Redirect 301 /services/dental-implants https://chaggerdental.com/service/dental-implants
    Redirect 301 /services/dentures https://chaggerdental.com/service/denture-services
    Redirect 301 /services/endodontics https://chaggerdental.com/service/endodontics
    Redirect 301 /services/invisalign https://chaggerdental.com/service/invisalign
    Redirect 301 /services/porcelain-veneers https://chaggerdental.com/service/porcelain-veneers
    Redirect 301 /services/restorations https://chaggerdental.com
    Redirect 301 /services/teeth-whitening https://chaggerdental.com/service/teeth-whitening
    Redirect 301 /blog/maryland-dental-bridge https://chaggerdental.com
    Redirect 301 /blog/dental-crown-costs https://chaggerdental.com
    Redirect 301 /blog/dental-implants-and-orthodontic https://chaggerdental.com
    Redirect 301 /blog/dental-hygienist-vs-dentist-meaning-roles-simulation-and-differences https://chaggerdental.com
    Redirect 301 /blog/types-of-cavities https://chaggerdental.com
    Redirect 301 /blog/how-much-does-a-root-canal-cost https://chaggerdental.com
    Redirect 301 /blog/a-guide-to-the-differences-between-dental-implant-procedures https://chaggerdental.com
    Redirect 301 /blog/what-is-gingivoplasty https://chaggerdental.com
    Redirect 301 /blog/dental-implants-and-their-advantages https://chaggerdental.com
    Redirect 301 /blog/permanent-dentures https://chaggerdental.com
    Redirect 301 /blog/professional-teeth-whitening https://chaggerdental.com
    Redirect 301 /blog/postoperative-period-like-after-a-gum-graft https://chaggerdental.com
    Redirect 301 /blog/dental-bridges-vs-dental-implants https://chaggerdental.com
    Redirect 301 /blog/is-red-wine-really-able-to-improve-your-oral-health https://chaggerdental.com
    Redirect 301 /blog/tips-to-choosing-your-dentist https://chaggerdental.com
    Redirect 301 /blog/remove-black-tartar-from-teeth https://chaggerdental.com
    Redirect 301 /blog/gum-disease-causes-and-treatment-options https://chaggerdental.com
    Redirect 301 /blog/how-to-correct-crowded-teeth-causes-and-best-treatments https://chaggerdental.com
    Redirect 301 /blog/flexible-dental-prostheses https://chaggerdental.com
    Redirect 301 /blog/gum-graft-surgery https://chaggerdental.com
    Redirect 301 /blog/complete-guide-to-fixed-dentures https://chaggerdental.com
    Redirect 301 /blog/chagger-dental-your-trusted-dentist-in-burlington https://chaggerdental.com
    Redirect 301 /blog/chagger-dental-your-trusted-choice-for-dental-implants-in-mississauga https://chaggerdental.com
    Redirect 301 /blog/types-of-dentists-you-should-know-about https://chaggerdental.com
    Redirect 301 /blog/teeth-move-again-after-orthodontics https://chaggerdental.com
    Redirect 301 /blog/how-long-does-a-dental-cleaning-last https://chaggerdental.com
    Redirect 301 /blog/what-are-the-roles-of-a-dental-hygienist https://chaggerdental.com
    Redirect 301 /blog/peg-teeth-mean-and-its-possible-treatment https://chaggerdental.com
    Redirect 301 /blog/walk-in-dentist https://chaggerdental.com
    Redirect 301 /blog/types-of-dental-fillings https://chaggerdental.com
    Redirect 301 /blog/why-do-my-gums-bleed-when-i-brush-my-teeth https://chaggerdental.com
    Redirect 301 /blog/how-to-securely-hold-lower-denture https://chaggerdental.com
    Redirect 301 /blog/dental-glue https://chaggerdental.com
    Redirect 301 /blog/what-to-do-if-my-denture-breaks https://chaggerdental.com
    Redirect 301 /blog/dental-freezing https://chaggerdental.com
    Redirect 301 /blog/invisalign-vs-braces-which-is-the-best-option https://chaggerdental.com
    Redirect 301 /blog/how-long-does-it-take-for-a-dental-implant-to-heal https://chaggerdental.com
    Redirect 301 /blog/dentist-hygienist-and-dental-assistant https://chaggerdental.com
    Redirect 301 /blog/what-is-aesthetic-orthodontics-and-what-are-its-benefits https://chaggerdental.com
    Redirect 301 /blog/understanding-malocclusion-causes-types-and-effective-treatments https://chaggerdental.com
    Redirect 301 /blog/dental-fracture https://chaggerdental.com
    Redirect 301 /blog/professional-teeth-whitening-what-does-he-have-that-the-rest-dont https://chaggerdental.com
    Redirect 301 /blog/why-do-children-get-white-spots-on-their-teeth https://chaggerdental.com
    Redirect 301 /blog/what-is-dental-malocclusion https://chaggerdental.com
    Redirect 301 /blog/need-to-know-about-root-canal https://chaggerdental.com
    Redirect 301 /blog/6-effective-answers-to-dealing-with-tooth-decay-and-reversing-cavities https://chaggerdental.com
    Redirect 301 /blog/what-are-orthodontic-retainers https://chaggerdental.com
    Redirect 301 /blog/causes-of-halitosis https://chaggerdental.com
    Redirect 301 /blog/foods-for-healthy-teeth-and-gums https://chaggerdental.com
    Redirect 301 /blog/oakvilles-premier-dentistry https://chaggerdental.com
    Redirect 301 /blog/dental-bridges-cost https://chaggerdental.com
    Redirect 301 /blog/why-is-it-important-to-go-to-the-dentist-for-checkups https://chaggerdental.com
    Redirect 301 /blog/dental-implants-in-the-whole-mouth https://chaggerdental.com
    Redirect 301 /blog/brush-your-teeth-every-day https://chaggerdental.com
    Redirect 301 /blog/partial-dentures-for-front-teeth https://chaggerdental.com
    Redirect 301 /blog/zirconia-dental-implants https://chaggerdental.com
    Redirect 301 /blog/invisalign-express-orthodontics https://chaggerdental.com
    Redirect 301 /blog/professional-teeth-whitening-what-does-he-have-that-the-rest-don’t https://chaggerdental.com
    Redirect 301 /blog/smile-makeover https://chaggerdental.com
    Redirect 301 /blog/dental-hygienist-vs-dentist https://chaggerdental.com
    Redirect 301 /blog https://chaggerdental.com
 
    # Remove /live/public from URLs
    RewriteCond %{THE_REQUEST} \s/+live/public/([^\s]+) [NC]
    RewriteRule ^live/public/(.*)$ /$1 [R=301,L]

    # -----------------------------------
    # 3. LARAVEL (LAST - VERY IMPORTANT)
    # -----------------------------------

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript application/json
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/webp "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
</IfModule>

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php83” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php83 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
