Skip to main content

. htaccess Tips & Tricks

Force HTTP to HTTPS (SSL):

RewriteOptions inherit
Options -Indexes
#SecFilterEngine Off

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

<IfModule mod_alias.c>
</IfModule>

 

Change default DocumentRoot directory

This is possible via .htaccess. You will need to add the following code in your .htaccess file:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteCond %{REQUEST_URI} !folder/
RewriteRule (.*) /folder/$1 [L]

Replace ‘domain.com‘ with your domain name and ‘folder‘ with your custom folder name where you kept the index.

The proper, but long way of changing

How to change the document root for a cPanel account