On most cPanel hosting, mod_rewrite is already enabled by the host, so you don't switch the module on yourself. You turn the rewrite engine on for your site by adding RewriteEngine On to the .htaccess file in your website's folder, which you can do in cPanel's File Manager in about a minute.

If you run your own VPS or dedicated server with WHM, mod_rewrite comes with the Apache package that EasyApache 4 installs, so the job there is to confirm it's loaded rather than install it. This guide covers both cases, a simple test rule to prove rewrites work, and what changes on LiteSpeed servers.

I manage client websites in cPanel, so the steps below follow cPanel's current File Manager and WHM interfaces as described in the official cPanel documentation.

Contents
  1. What will you need to enable the rewrite module?
  2. How to enable mod_rewrite in cPanel?
  3. How to enable mod_rewrite on a VPS or dedicated server with WHM
  4. LiteSpeed servers and mod_rewrite
  5. How do I know if mod_rewrite is enabled?
  6. Conclusion
  7. FAQ (Frequently Asked Questions)

What will you need to enable the rewrite module?

Here's what you need before you start.

  • Access to cPanel: You need a login for the cPanel account that hosts the website.
  • Apache or LiteSpeed web server: mod_rewrite is an Apache module. cPanel servers run Apache by default, and many hosts use LiteSpeed Web Server instead, which reads the same rewrite rules from .htaccess.
  • Mod_rewrite status: On shared hosting, the host controls the server modules. cPanel itself has no switch for Apache modules, so check your host's knowledge base or ask support if you're unsure. Server admins can check in WHM (see the WHM section below).
  • Ability to edit the .htaccess file: You can edit it in cPanel's File Manager or over FTP/SFTP. Every cPanel account allows this.

editing htaccess file

How to enable mod_rewrite in cPanel?

Follow these steps to turn on the rewrite engine for your website. If you're new to the file itself, my .htaccess guide explains what else it controls.

Step 1: Head over to the file manager from cPanel

Log in to cPanel and open File Manager in the Files section.

navigating to cpanels file manager

Then open the public_html folder, or the document root of the domain you're working on (addon domains often have their own folder).

Step 2: Open .htaccess file

Files that start with a dot are hidden by default. If you don't see .htaccess, click Settings in the top-right corner, check Show Hidden Files (dotfiles) and click Save.

cpanel settings showing hidden files

Now right-click .htaccess and choose Edit. If an encoding dialog appears, keep the suggested encoding (usually UTF-8) and click Edit again. If the file doesn't exist, use + File in the toolbar to create one named .htaccess.

htaccess file editing

Make a copy first. Right-click the file, choose Copy and save it as something like .htaccess-backup. A single typo in .htaccess can take the whole site down with a 500 error.

Step 3: Enable Mod_rewrite

Your .htaccess file will either already have some code or be empty.

If it has code, look for RewriteEngine Off and change it to RewriteEngine On. If the file has no RewriteEngine line at all, add RewriteEngine On above your first RewriteRule. WordPress sites usually have it already, inside the # BEGIN WordPress block.

enabling mod rewrite via htaccess

If the file is empty, add this line:

RewriteEngine On

Click Save Changes and close the editor tab. The change works immediately: there's no Apache restart on shared hosting.

That's it: the rewrite engine is on for that folder and everything below it. Rules you add underneath it (redirects, pretty URLs, forcing HTTPS) will now run.

How to enable mod_rewrite on a VPS or dedicated server with WHM

If you have root access and WHM, the module itself is managed by EasyApache 4, cPanel's tool for building the Apache and PHP stack.

In EasyApache 4, mod_rewrite ships inside the core Apache package (ea-apache24) and is loaded by default. That's why it doesn't show up as a separate checkbox in the Apache Modules step, which lists optional modules such as ModSecurity, HTTP2 or Brotli.

To confirm it's loaded, connect over SSH as root and run:

httpd -M | grep rewrite

The output rewrite_module (shared) means it's active. If nothing comes back:

  1. Check that /etc/apache2/conf.modules.d/ still contains the rewrite module's config file with its LoadModule rewrite_module line, and that the line isn't commented out.
  2. In WHM » Home » Software » EasyApache 4, click Customize on your current profile, go through the steps to Review and click Provision. This rebuilds the stack from the profile, including the core Apache package.
  3. Restart Apache with /usr/local/cpanel/scripts/restartsrv_httpd and run the check again.

Don't edit /etc/apache2/conf/httpd.conf by hand on a cPanel server. cPanel regenerates it, so put custom Apache directives in WHM » Service Configuration » Apache Configuration » Include Editor instead.

Not on cPanel? On a plain Debian or Ubuntu server, the commands are different: sudo a2enmod rewrite, then sudo systemctl restart apache2. These don't apply to cPanel servers.

LiteSpeed servers and mod_rewrite

Many cPanel hosts run LiteSpeed Web Server instead of Apache. LiteSpeed Enterprise reads your .htaccess rewrite rules the same way, so the steps above don't change, and it picks up .htaccess changes without a restart.

OpenLiteSpeed (the free edition) also uses mod_rewrite syntax, but it only loads .htaccess changes after a server restart. One behavior differs on both versions: LiteSpeed stops processing rules at an [L] flag, while Apache only stops the current pass, so a rule set that loops on Apache can behave differently on LiteSpeed.

How do I know if mod_rewrite is enabled?

There are several ways to check if mod_rewrite is enabled. On shared hosting, the first one is the only method that tests the live site, so start there.

1. Using .htaccess File:

You can test the rewrite engine from the .htaccess file itself. Below the RewriteEngine On line, add this test rule:

RewriteRule ^mod-rewrite-test$ / [R=302,L]

It sends anyone who opens yoursite.com/mod-rewrite-test to your homepage.

Open that address in your browser. If you land on the homepage, mod_rewrite is working. To see the redirect itself, press F12, click Network and reload: the test address shows a 302 status. Remove the test rule when you're done.

checking mod rewrite status

If the whole site shows a 500 Internal Server Error right after you add RewriteEngine On, the module isn't loaded. Apache logs "Invalid command 'RewriteEngine'" in that case, and cPanel shows it under Metrics » Errors. Restore your backup and ask the host to enable mod_rewrite.

2. Checking Apache Configuration Files

This needs root access, so it's for VPS and dedicated servers. On a cPanel server, the main config file is /etc/apache2/conf/httpd.conf, and EasyApache 4 loads modules from files in /etc/apache2/conf.modules.d/.

Search those files for the module line:

grep -r "rewrite_module" /etc/apache2/conf.modules.d/

A result like this means Apache loads the module:

LoadModule rewrite_module modules/mod_rewrite.so

3. Using PHPInfo()

Create a file named info.php in public_html with this code:

<?php
phpinfo();

Open https://yourdomain.com/info.php and look for the apache2handler section, which lists Loaded Modules.

confirm loaded modules via phpinfo

This only works when PHP runs as an Apache module. Most cPanel servers now run PHP through PHP-FPM, CGI or LiteSpeed's LSAPI, and then the page doesn't list Apache modules at all. Delete info.php afterward, because it shows details about your server to anyone who finds it.

4. Command Line (On Linux)

With SSH access, run httpd -M | grep rewrite on a cPanel server. On Debian or Ubuntu servers without cPanel, the same check is:

apache2ctl -M | grep rewrite

If the output shows rewrite_module (shared) or rewrite_module (static), the module is enabled. No output means it isn't loaded.

checking mod rewrite via command line

This needs SSH or Terminal access, which many shared plans limit or leave out, so on shared hosting the .htaccess test is the easier check.

5. Asking Hosting Provider

The quickest check is to ask your hosting provider. Many hosts also cover it in their knowledge base. Hostinger, for example, says mod_rewrite is preinstalled and active on its Web and Cloud hosting plans.

mod rewrite pre installed in hostinger

One exception there: on Hostinger's Agency plans, .htaccess support is disabled by default and has to be switched on in the site's settings in hPanel.

Conclusion

On shared cPanel hosting, enabling mod_rewrite means adding RewriteEngine On to your .htaccess file, because the host has already loaded the module. A quick test redirect tells you within a minute whether rewrites work.

On your own server with WHM, mod_rewrite comes with EasyApache 4's core Apache package, and httpd -M confirms it. If a host's shared plan really doesn't support it, ask support to enable it, or treat it as a sign to look at another host.

FAQ (Frequently Asked Questions)

What is mod_rewrite?

Mod_rewrite is an Apache module that rewrites and redirects URLs based on rules. WordPress uses it for pretty permalinks, and site owners use it for redirects such as forcing HTTPS or removing "www".

Can you enable mod_security from cPanel?

Yes, if your host has installed it. Open ModSecurity in cPanel's Security section, where you can turn it on or off for all domains or for each domain. If you don't see the icon, the server admin has to install ModSecurity in EasyApache 4 and enable the ModSecurity Domain Manager feature for your account.