# Enable mod_rewrite
RewriteEngine On

# ============================
# Step 1: Redirect HTTP to HTTPS and Ensure 'www' in one go
# ============================
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^voisiptv\.com$ [NC]
RewriteRule ^ https://www.voisiptv.com%{REQUEST_URI} [R=301,L]

# ============================
# Step 2: Redirect root (/) to /index directly
# ============================
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^$ https://www.voisiptv.com/index [R=301,L]

# ============================
# Step 3: Redirect /home to /index (force the redirection)
# ============================
# RewriteCond %{REQUEST_URI} ^/home$ [NC]
# RewriteRule ^home$ https://www.voisiptv.com/index [R=301,L]

# ============================
# Step 4: Remove index.html if accessed directly
# ============================
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ https://www.voisiptv.com/ [R=301,L]


# ============================
# Step 5: Remove trailing slash if it's not a directory
# ============================
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]



RewriteRule ^video-guide$ /video-guide.php [L]



RewriteRule ^about-us.html$ /about-us [R=301,L]
RewriteRule ^about$ /about.php [L]
# RewriteRule ^home$ /home.php [L]
RewriteRule ^index$ /index.php [L]


Redirect 301 /terms-andconditions https://www.voisiptv.com/
Redirect 301 /iptv-set-top-box/  https://www.voisiptv.com/iptv-set-top-box
RewriteRule ^ip-tv-set-top-box$ /ip-tv-set-top-box.php [L]



RewriteRule ^channels.html$ /iptv-indian-channels [R=301,L]
RewriteRule ^iptv-indian-channels$ /iptv-indian-channels.php [L]

RewriteRule ^punjabi-channels.html$ /punjabi-iptv-channels [R=301,L]
RewriteRule ^punjabi-iptv-channels$ /punjabi-iptv-channels.php [L]

RewriteRule ^hindi-channels.html$ /hindi-iptv-channels [R=301,L]
RewriteRule ^hindi-iptv-channels$ /hindi-iptv-channels.php [L]


RewriteRule ^hindi-channels.html$ /hindi-iptv-channels [R=301,L]
RewriteRule ^hindi-iptv-channels$ /hindi-iptv-channels.php [L]

RewriteRule ^english-channels.html$ /english-iptv-channels [R=301,L]
RewriteRule ^english-iptv-channels$ /english-iptv-channels.php [L]

RewriteRule ^urdu-channels.html$ /urdu-iptv-channels [R=301,L]
RewriteRule ^urdu-iptv-channels$ /urdu-iptv-channels.php [L]

RewriteRule ^bengali-channels.html$ /bengali-iptv-channels [R=301,L]
RewriteRule ^bengali-iptv-channels$ /bengali-iptv-channels.php [L]


RewriteRule ^nepali-channels.html$ /nepali-iptv-channels [R=301,L]
RewriteRule ^nepali-iptv-channels$ /nepali-iptv-channels.php [L]

RewriteRule ^marathi-channels.html$ /marathi-iptv-channels [R=301,L]
RewriteRule ^marathi-iptv-channels$ marathi-iptv-channels.php [L]

RewriteRule ^tamil-channels.html$ /tamil-iptv-channels [R=301,L]
RewriteRule ^tamil-iptv-channels$ tamil-iptv-channels.php [L]

RewriteRule ^telugu-channels.html$ /telugu-iptv-channels [R=301,L]
RewriteRule ^telugu-iptv-channels$ telugu-iptv-channels.php [L]

RewriteRule ^telugu-channels.html$ /telugu-iptv-channels [R=301,L]
RewriteRule ^telugu-iptv-channels$ telugu-iptv-channels.php [L]

RewriteRule ^malayalam-channels.html$ /malayalam-iptv-channels [R=301,L]
RewriteRule ^malayalam-iptv-channels$ malayalam-iptv-channels.php [L]

RewriteRule ^kannada-channels.html$ /kannada-iptv-channels [R=301,L]
RewriteRule ^kannada-iptv-channels$ kannada-iptv-channels.php [L]

RewriteRule ^gujarati-channels.html$ /gujarati-iptv-channels [R=301,L]
RewriteRule ^gujarati-iptv-channels$ gujarati-iptv-channels.php [L]

RewriteRule ^iptv-app.html$ /iptv-app[R=301,L]
RewriteRule ^iptv-app$ iptv-app.php [L]


RewriteRule ^srilankan-channels.html$ /srilankan-iptv-channels [R=301,L]
RewriteRule ^srilankan-iptv-channels$ srilankan-iptv-channels.php [L]


RewriteRule ^set-top-box.html$ /iptv-set-top-box [R=301,L]
RewriteRule ^iptv-set-top-box$ iptv-set-top-box.php [L]

RewriteRule ^faq.html$ /faq [R=301,L]
RewriteRule ^faq$ faq.php [L]

RewriteRule ^contact-us.html$ /contact-us [R=301,L]
RewriteRule ^contact$ contact.php [L]

RewriteRule ^contact-us$ /contact [R=301,L]
RewriteRule ^contact-us$ contact [L]

RewriteRule ^buy-iptv-subscription$ /buy-now [R=301,L]
RewriteRule ^buy.html$ /buy [R=301,L]
RewriteRule ^buy.php$ /buy-iptv-subscription [R=301,L]
RewriteRule ^buy$ buy.php [L]
RewriteRule ^buy-iptv-subscription$ /buy-iptv-subscription.php [L]
RewriteRule ^buy-now$ /buy-now.php [L]


RewriteRule ^terms-and-conditions.html$ /terms-and-conditions [R=301,L]
RewriteRule ^terms-and-conditions$ terms-and-conditions.php [L]



RewriteRule ^iptv-services-toronto$ /iptv-services-toronto.php [L]
RewriteRule ^iptv-services-vancouver$ /iptv-services-vancouver.php [L]
RewriteRule ^iptv-services-montreal$ /iptv-services-montreal.php [L]
RewriteRule ^iptv-services-calgary$ /iptv-services-calgary.php [L]
RewriteRule ^iptv-services-ottawa$ /iptv-services-ottawa.php [L]
RewriteRule ^iptv-services-brampton$ /iptv-services-brampton.php [L]
RewriteRule ^iptv-services-surrey$ /iptv-services-surrey.php [L]
RewriteRule ^iptv-services-quebec$ /iptv-services-quebec.php [L]
RewriteRule ^iptv-services-edmonton$ /iptv-services-edmonton.php [L]

RewriteRule ^locations$ /locations.php [L]

RewriteRule ^privacy-policy.html$ /privacy-policy [R=301,L]
RewriteRule ^privacy-policy$ /privacy-policy.php [L]

RewriteRule ^privacy-policy.html$ /privacy-policy [R=301,L]
RewriteRule ^privacy-policy$ /privacy-policy.php [L]


RewriteRule ^sitemap.html$ /sitemap [R=301,L]
RewriteRule ^sitemap$ /sitemap.php [L]

ErrorDocument 404 /404.php







# Force HTTPS for images, CSS, JS
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteCond %{REQUEST_URI} \.(jpg|jpeg|png|gif|css|js|svg|webp)$ [NC]
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>


# Enable Gzip Compression for CSS, JS, HTML and other text-based files
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/json
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xml+rss
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE font/truetype
    AddOutputFilterByType DEFLATE font/opentype
    AddOutputFilterByType DEFLATE font/woff
    AddOutputFilterByType DEFLATE font/woff2
    AddOutputFilterByType DEFLATE image/webp

    # Remove browser bugs
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    Header append Vary User-Agent
</IfModule>




# Leverage Browser Caching for images, CSS, and JS
<IfModule mod_expires.c>
    ExpiresActive On

    # Images (cache for 1 year)
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/webp "access plus 1 year"
    ExpiresByType image/svg+xml "access plus 1 year"

    # CSS and JS (cache for 1 month)
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType application/x-javascript "access plus 1 month"

    # HTML (cache for 1 week)
    ExpiresByType text/html "access plus 1 week"
</IfModule>

# Enable Brotli Compression
<IfModule mod_brotli.c>
    AddOutputFilterByType BROTLI_COMPRESS text/html text/css text/javascript application/javascript application/json application/xml
</IfModule>

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