# EHX by ADEON — Apache config
Options -Indexes
DirectoryIndex index.php

RewriteEngine On

# Force HTTPS and non-www
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://ehx.ae%{REQUEST_URI} [L,R=301]

# Redirect /page.php to /page
RewriteCond %{THE_REQUEST} \s/([a-z0-9-]+)\.php[\s?] [NC]
RewriteRule ^ /%1 [L,R=301]

# Serve /page from page.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([a-z0-9-]+)/?$ $1.php [L]

# Block direct access to includes and config
RewriteRule ^(includes/|config\.php) - [F,L]

<IfModule mod_headers.c>
  Header set X-Content-Type-Options "nosniff"
  Header set X-Frame-Options "SAMEORIGIN"
  Header set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/css "access plus 1 month"
</IfModule>
