<IfModule mod_rewrite.c>
RewriteEngine On

# 1. Redirect HTTP to HTTPS (Updated Rule for Proxies/Cloudflare)
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# 2. Redirect non-www to www
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.ilovepdffree.in/$1 [L,R=301]

</IfModule>

# Set your custom 404 error page
ErrorDocument 404 /404.html