# ============================================
# URL REDIRECTS
# ============================================

RewriteEngine On

# Force the production canonical host and HTTPS.
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} !^innovarerenovations\.com\.au$ [NC]
RewriteRule ^ https://innovarerenovations.com.au%{REQUEST_URI} [R=301,L]


# ============================================
# DYNAMIC XML SITEMAP
# ============================================

RewriteRule ^sitemap\.xml$ sitemap.php [L]


# ============================================
# CANONICAL URL REDIRECTS
# ============================================

# Redirect index.html to the root domain.
RewriteCond %{THE_REQUEST} \s/+index\.html[\s?] [NC]
RewriteRule ^index\.html$ https://innovarerenovations.com.au/ [R=301,L]

# Redirect contact.php to /contact.
RewriteCond %{THE_REQUEST} \s/+contact\.php[\s?] [NC]
RewriteRule ^contact\.php$ /contact [R=301,L]

# Redirect .html URLs to extensionless URLs.
# Example: /about.html -> /about
RewriteCond %{THE_REQUEST} \s/+(.+)\.html[\s?] [NC]
RewriteRule ^(.+)\.html$ /$1 [R=301,L]

# Remove trailing slashes from non-directory public URLs.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]


# ============================================
# SERVE .HTML FILES WITHOUT SHOWING .HTML
# ============================================

# If /about is requested, internally load /about.html.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule ^(.+?)/?$ $1.html [L]

# If /contact is requested, internally load /contact.php.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]


# ============================================
# 404 PAGE
# ============================================

# If the requested URL does not exist, show 404.html.
ErrorDocument 404 /404.html


# ============================================
# SEO RESPONSE HEADERS
# ============================================

<IfModule mod_headers.c>
    Header set X-Robots-Tag "index, follow"
</IfModule>


# ============================================
# PROCESS HTML THROUGH PHP
# ============================================

# Process existing .html pages through PHP
# so the shared/dynamic head template can run.
<IfModule mime_module>
    AddHandler application/x-httpd-ea-php82 .html .htm
</IfModule>


# ============================================
# BEGIN cPanel-GENERATED PHP INI DIRECTIVES
# ============================================

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor
# (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation:
# https://go.cpanel.net/EA4ModifyINI

<IfModule php8_module>
    php_value error_log "/home/innovare/logs/php.error.log"
    php_flag log_errors On
</IfModule>

<IfModule lsapi_module>
    php_value error_log "/home/innovare/logs/php.error.log"
</IfModule>

# END cPanel-generated php ini directives


# ============================================
# PHP HANDLER
# ============================================

# 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