Enable Mod Rewrite Module

How to Enable Mod-Rewrite Module?

You can enable mod_rewrite by adding the following line in the .htaccess file of your website.

RewriteEngine On

You can customize the rules below this rule based on your requirement.

For example, I have provided you the rules for force Http to Https redirection through .htaccess which is added below RewriteEngine rule.

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

Content Management System like WordPress by default will have RewriteEngine ON in their .htaccess file. Below you can see the default .htaccess file of WordPress. If you would like to add the above https redirection line, then you can add it before # END WordPress

# BEGIN WordPress
RewriteEngine On
RewriteBase / RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

How To View and Edit .Htaccess in cPanel:

  1. Login to cPanel
  2. Select “File Manager” Option
  3. Click on “Settings” on the right top corner of your cPanel interface.
  4. Select the Checkbox “Show Hidden Files (dotfiles)” to view .htaccess file.
  5. Right Click on .htaccess file and use the edit option to do modification in the file.

[Tweet “How to Enable Mod-Rewrite Module?”]