==============================================================================
TelegramDownloader.net - Optimized .htaccess File
Version 1.1 - non-WWW
==============================================================================
Enable the rewrite engine, which is necessary for the rules below to work.
RewriteEngine On

------------------------------------------------------------------------------
SECTION 1: CANONICAL URLS (SEO BEST PRACTICES)
------------------------------------------------------------------------------
1a. Force HTTPS (Secure Connection)
Redirect all HTTP traffic to HTTPS for security and SEO benefits.
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

1b. Force non-WWW
Redirect www requests to non-www to avoid duplicate content.
RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [L,R=301]

1c. Remove "index.html" from URLs
If a user visits domain.com/index.html, they will be redirected to domain.com/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.html\ HTTP/
RewriteRule ^index.html$ https://%{HTTP_HOST}/ [L,R=301]

------------------------------------------------------------------------------
SECTION 2: PRETTY URLS (Remove .html extension)
------------------------------------------------------------------------------
This block allows users to access pages without the .html extension.
Condition: The request is NOT for an existing file.
RewriteCond %{REQUEST_FILENAME} !-f

Condition: The request is NOT for an existing directory.
RewriteCond %{REQUEST_FILENAME} !-d

Condition: The request is NOT for the /blog/ directory (to allow WordPress to handle it).
RewriteCond %{REQUEST_URI} !^/blog/

Rule: If the request + .html exists as a file, serve it.
RewriteRule ^([^/]+)/?$ $1.html [L]

------------------------------------------------------------------------------
SECTION 3: BROWSER CACHING (PERFORMANCE OPTIMIZATION)
------------------------------------------------------------------------------
Instructs browsers to cache static files for a long time, improving load speed for repeat visitors.
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "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"
ExpiresByType image/x-icon "access plus 1 year"

ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"

ExpiresByType application/font-woff2 "access plus 1 year"
</IfModule>

------------------------------------------------------------------------------
SECTION 4: BASIC SECURITY HEADERS
------------------------------------------------------------------------------
<IfModule mod_headers.c>

Prevents browsers from incorrectly guessing content types.
Header set X-Content-Type-Options "nosniff"

Prevents the site from being embedded in an iframe on other sites (clickjacking protection).
Header set X-Frame-Options "SAMEORIGIN"

Enables basic cross-site scripting (XSS) protection in older browsers.
Header set X-XSS-Protection "1; mode=block"
</IfModule>

END of .htaccess configuration.