#Note
Before making any changes to the
.htaccess
file must checkRewriteEngine
is set toOn
.
RewriteEngine On
#Redirect Browser to HTTPS
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
#OR
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#Redirect Browser to HTTP
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#Set the Time Zone
SetEnv TZ Asia/Kolkata
#Remove the www from your URL.
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
#Custom Error Pages
ErrorDocument 400 /400.html
ErrorDocument 401 /401.html
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
#Set DirectoryIndex
DirectoryIndex index.php
configure multiple index files as a fallback.
DirectoryIndex index.php index.html index.htm