How Can I Enable Mod_Rewrite Module?

After moving your website, you can rewrite the URLs to forward visitors to the new domain name, saving you from traffic and potential sales losses. 

You can also rewrite ugly and unwieldy URLs (like to make them intuitive for shoppers, for example, to something like 

The link is easier on the eyes, looks clean, and visitors can extract semantic meanings.

Of course, enabling the mod_rewrite module makes this possible. So let’s learn what it’s, how it works and how to enable it for your account.

What’s Mod_Rewrite?

The mod_rewrite  is an Apache module that helps users manipulate or rewrite URLs from the server, allowing them to offer different URLs for the same file.

The module uses a rule-based rewriting engine to let users rewrite URLs.

Users can enable the .htaccess file after activating the mod_rewriting module to let them rewrite URLs via the file on their account control panel instead of on their remote servers. 

The .htaccess file allows people to configure server settings without accessing its configuration files.

How the Rewrite Rule Works

The mod_rewrite module relies on rules to match URLs.

When a visitor makes a URL request, the module checks the incoming URLs against existing rules, which use regular expressions to define the match condition or pattern. 

If the URL matches a rule, it checks the defined condition and proceeds to the next rule until there are no more rules left, and then executes the substitution.

For instance, if you set up a rewrite rule that forwards users from www to non-www when they make a page request, the module will compare the URL against all existing rules>

If it matches the www to non-www rewrite rule and other defined rules (for instance, HTTP to HTTPS redirect), it executes all the rewrites at once.

The mod_write syntax follows this pattern RewriteRule Pattern Substitution [Flags]:

  • RewriteRule specifies the name of the mod_rewrite directive you want to use.
  • Pattern shows the regular expression that matches the requested URL.
  • Substitution defines the URL of the page you wish to forward to or display.
  • Flags specify additional but optional parameters.

Here’s a sample mod_rewrite rule syntax for redirecting non-www URLs to www.

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\. [NC]

RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Importance of Mod_Rewrite

Mod_write’s flexibility makes it so powerful and exciting; let’s examine some of its benefits quickly:

  • The module helps users to rewrite ugly URLs into friendlier and clean URLs.
  • It allows users to redirect visitors from www to non-www URLs or vice versa, which helps address duplicate content issues.
  • You can redirect web visitors to your new domain name when you change the domain using a mod_rewrite rule.
  • You can block specific or multiple IP addresses using a rewrite rule.
  • Most international eCommerce uses mod_rewrite rules to forward visitors from certain countries to the right place, category or store.
  • You can deny users access to certain file types, like .pdf, .css, and others.
  • It helps web admins force their websites to load securely using HTTPS. 

Enabling Mod_Rewrite Module

Scala Hosting installs and enables mod-rewrite modules on Apache web servers by default. If the module is not enabled for you, contact our support, and we’ll get it done.

But if you wish to enable it yourself, then head to your server and find the global configuration file, httpd.conf.

Locate the section that loads a bunch of modules and find the line below within the file.

LoadModule rewrite_module modules/mod\

Uncomment the line if it’s commented out by removing the hashtag (#) at the beginning of the line. Please ensure to make a backup of your file before modifying the global configuration file.

Need Support?

Scala Hosting installs and enables Apache mod_rewrite on your server by default, so you don’t have to worry about modifying your server global configuration file. 

But if you have questions relating to mod_rewrite, you can reach out to our support, and we’ll be glad to answer them.

Was this helpful?

What’s your goal today?

1. Find the right Managed VPS solution

If you’re looking for industry-leading speed, ease of use and reliability Try ScalaHosting with an unconditional money-back guarantee.

2. Make your website lighting fast

We guarantee to make your WordPress site load in less than 2 seconds on a managed VPS with ScalaHosting or give your money back. Fill out the form, and we’ll be in touch.

Please enter a valid name
Please enter a valid website
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

3. Streamline your clients’ hosting experience

If you’re a web studio or development agency hosting more than 30 websites, schedule a call with Vlad, our co-founder and CTO, and see how we can deliver unmatched value to both your business and your clients.


Need a custom cluster or professional advice?

Book a meeting and get a free 30-minute consultation with Vlad, co-founder & CTO of Scala Hosting, who will help you select, design and build the right solution - from a single data center cluster to a multi-region & multi-datacenter high availability cluster with hundreds of servers.

Book a free consultation

4. Learn how to grow your website in 2024

An all-star team of SEO and web influencers are sharing their secret knowledge for the first time in years. Learn about the future of SEO, Web Design best practices and the secrets to getting the foundation for your website to thrive. Watch the exclusive webinar.

An Exclusive Insiders Look Behind The SEO and Web Development Curtain


Working in the web hosting industry for over 13 years, Rado has inevitably got some insight into the industry. A digital marketer by education, Rado is always putting himself in the client's shoes, trying to see what's best for THEM first. A man of the fine detail, you can often find him spending 10+ minutes wondering over a missing comma or slightly skewed design.