RewriteEngine on
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule . /index.php [L]

#RedirectMatch "^/join/?$" "/auth/join" // redirect a simple url to a specific page
#RedirectMatch "^/join-beta/?$" "https://someothersite.com" // redirect a simple url to a specific page

#RedirectMatch "^/terms/?$" "/terms-of-use"
#RedirectMatch "^/join-beta/?$" "https://someothersite.com"

#RewriteRule ^(r)/?$ /$1.php [L,NC]
#RewriteRule ^(.*)$ $1.php
#RewriteRule ^r$ r.php [L]

#Security Headers
<IfModule mod_headers.c>
Header always set X-XSS-Protection "1; mode=block"
Header always set Referrer-Policy: "no-referrer"
Header always append X-Frame-Options SAMEORIGIN
Header always set X-Content-Type-Options nosniff
Header always set Content-Security-Policy "default-src 'self' 'unsafe-eval' 'unsafe-inline' *.googleapis.com *.js fonts.gstatic.com jquery.datetimepicker.js cdn.jsdelivr.net cdnjs.cloudflare.com www.youtube.com youtube.com maxcdn.bootstrapcdn.com www.google-analytics.com img-src https: data:;"
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS
Header always set Expect-CT: enforce,max-age=7776000,report-uri="https://base.basepages.com/report-ct"
</IfModule>

# BEGIN GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
# END GZIP

<Files "apple-app-site-association">
ForceType 'application/json'
</Files>
# iOS
#RewriteRule ^apple-app-site-association$ apple-app-site-association.json [NC,L]

<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js|webmanifest)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>

#ErrorDocument 404 http://www.domain.com/your-custom-404.php
#ErrorDocument 400 /error/bad-request.html
#ErrorDocument 401 /error/unauthorised.html
#ErrorDocument 403 /error/forbidden.html
#ErrorDocument 404 /error/file-not-found.html
#ErrorDocument 500 /error/internal-server-error.html

ErrorDocument 400 /error/404.html
ErrorDocument 401 /error/401.html
ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.html
ErrorDocument 500 /error/500.html

# 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 php7_module>
   php_flag display_errors On
   php_value max_execution_time 600
   php_value max_input_time 600
   php_value max_input_vars 1000
   php_value memory_limit 256M
   php_value post_max_size 256M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php73"
   php_value upload_max_filesize 256M
   php_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
   php_flag display_errors On
   php_value max_execution_time 600
   php_value max_input_time 600
   php_value max_input_vars 1000
   php_value memory_limit 256M
   php_value post_max_size 256M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php73"
   php_value upload_max_filesize 256M
   php_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated php ini directives, do not edit

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