# ------------------------------------------------------------
# cPanel PHP Handler (Leave This Exactly As-Is)
# ------------------------------------------------------------


# ------------------------------------------------------------
# ENABLE REWRITES
# ------------------------------------------------------------
RewriteEngine On


# ------------------------------------------------------------
# FORCE HTTPS AND REMOVE WWW
# ------------------------------------------------------------

# Redirect www → non-www
RewriteCond %{HTTP_HOST} ^www\.mockupsiteready\.com$ [NC]
RewriteRule ^(.*)$ https://mockupsiteready.com/$1 [R=301,L]

# Redirect http → https
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://mockupsiteready.com/$1 [R=301,L]


# ------------------------------------------------------------
# CLEAN URLS FOR STATIC HTML FILES
# /page/ → loads page.html
# /page.html → redirects to /page/
# ------------------------------------------------------------

# 1. Redirect .html → slash version
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s/+(.+?)\.html[\s?]
RewriteRule ^ %1/ [R=301,L]

# 2. Serve .html file when /folder-name/ is requested
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+?)/?$ $1.html [L]


# ------------------------------------------------------------
# DEFAULT INDEX FILE
# ------------------------------------------------------------
DirectoryIndex index.html index.htm


# ------------------------------------------------------------
# GZIP COMPRESSION
# ------------------------------------------------------------
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/xml
  AddOutputFilterByType DEFLATE text/css text/javascript application/javascript
  AddOutputFilterByType DEFLATE application/json application/xml application/rss+xml
  AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>


# ------------------------------------------------------------
# BROWSER CACHING
# ------------------------------------------------------------
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 1 month"

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

  # CSS & JS
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"

  # HTML
  ExpiresByType text/html "access plus 1 hour"
</IfModule>


# ------------------------------------------------------------
# SECURITY HEADERS
# ------------------------------------------------------------
<IfModule mod_headers.c>
  Header always set X-Frame-Options "SAMEORIGIN"
  Header always set X-XSS-Protection "1; mode=block"
  Header always set X-Content-Type-Options "nosniff"
  Header always set Referrer-Policy "strict-origin-when-cross-origin"
  Header always set Permissions-Policy "geolocation=(), camera=(), microphone=()"
</IfModule>


# ------------------------------------------------------------
# PROTECT THIS FILE
# ------------------------------------------------------------
<Files ".htaccess">
  Order Allow,Deny
  Deny from all
</Files>

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