Compare Mod-rewrite Hosting⚙ Filter Results
Oops! No Hosting Plans Match Your Search
You've selected a combination of features that none of the web hosts we profile offer. We suggest you remove your last filter or reset & start again.
Ask Our Experts
Need help with your hosting? Tell us exactly what you are looking for and we’ll do our very best to help. Please allow one working day for a response.
Please fill in all fields.
Thanks! Your request has been sent. We'll reply within 24 hours.
Recommended Host for Mod-rewrite
What is Mod_Rewrite Hosting?
mod_rewrite module is an Apache module that provides the ability to rewrite URL requests as they are made. This allows website users to see and interact with simple or "pretty" URLs instead of the complicated ones created by a web application.
You probably use URLs everyday, without thinking much about what is actually going on "under the hood." To understand how Apache
mod_rewrite works, and why you'd need it, we need to look at what a URL is and how dynamic web applications work.
Uniform What Locator?
A URL is a Uniform Resource Locator.
In the early days of the internet, the idea was that you were looking for some specific file, document, or image: a resource. The resource existed on some other computer, you just needed to know:
- The name of the computer it was on
- The path to the file itself.
The name of the computer is what we now call "the domain name," and evrything after the .com or .net (or .whatever) was the path to the file.
Web applications and URLs as query strings
Eventually, people started serving more than static documents and resources on their web server. People started building dynamic websites that would pull their content out of a database.
Imagine a typical CMS-driven blog website. Its natural, and desirable, to think of a single blog post as a document or resource. But that isn't really the way the computer is storing it.
The is some file, perhaps
index.php, that includes code to take an input id-number, make a call to the database, and then display the content of the post to the user.
The "real" URL for the blog post might be:
/index.php portion specifies the filename, and the
?post=342 is an input specifying that you want post number 342.
There are two problems with that.
The practical problem is that the URL doesn't contain any real information. This makes it hard to remember and unattractive to read. It just looks like gibberish. It gives search engines no information about the content of the post, either.
The philosophical problem, or conceptual problem, is that it breaks the idea that a post is a resource unto itself, a document. The semantic meaning of the URL is: "Show me the document at index.php, with the results of post=342 included." This is not what is actually intended, though.
Better URL structure
A better URL structure for post 342 might be:
An even better structure would be:
The second one is better because it contains more information about the post itself: the title and its category. But even the first is a lot better than before, because its structure suggests that the post number 342 is a unique entity, a resource or document with its own existence.
Benefits of a better URL structure
- Clean URLs are easier to remember, type, and transmit. People write down URLs, people say them over the phone to their friends, people hand-type them into emails (yes, instead of copy-and-paste — happens all the time).
- URLs that include category and titling information (called a "semantic" URL) are good for SEO, because they provide Search Engines with information about the content.
- Semantic URLs are implementation agnostic, meaning that the structure isn't dependent on the web application or CMS. This makes it easier in the future to change the underlying technology as needed without breaking the URLs.
- Because they are agnostic, pretty URLs identify a resource, not a way to get to it, which means that the underlying content can be edited, moved, changed, updated, or replaced without breaking the link between the identifier and the underlying resource.
How does mod_rewrite work?
Mod_rewrite is an Apache module that works at the level of the Apache web server. It handles incoming HTTP requests, and rewrites them according rules set up by the system's administrators (either directly or programatically).
For example, the public URL of a blog post might be:
There might then be a rule (written in special code and regular expressions) which takes the first portion, matching it to a category, and the second portion and matching it to a post slug:
From there, the
index.php file takes over and pulls content out of the database based on the query strings.
How does mod_rewrite get used?
It is possible for a system administrator to manually write request rewrite rules for a webserver. But this is somewhat rare.
More typically, a Content Management System (or similar framework) will include code that automatically inserts rewrite rules into the relevant configuration files based on settings. If you've ever used WordPress — this is what happens when you select your Permalink structure in the
Admin -> Settings menu.
mod_rewrite and web hosting
Not all dynamic web applications require
mod_rewrite in order to achieve pretty URLs. For example, Ruby on Rails uses its own internal routing mechanism, so clean URLs are sent directly to the application as they come in.
However, many web applications and content management systems require it. This is especially true of most PHP-based CMSes like WordPress and Drupal.
It is a very common feature of Apache web servers, but don't take it for granted. If you're going to need it, make sure you select a hosting provider that supports Apache mod_rewrite, and allows your installed apps to write new rewrite rules.
Mod-rewrite Hosting Frequently Asked Questions
What is mod_rewrite?
It is an Apache module that allows URLs to look different than they are.
It is commonly used in web applications such as WordPress and Joomla! Their pages are not very informative to humans. For example, a page might look like this:
Mod_rewrite allows programmers to mask this behavior by assigning a "pretty" URL as a stand in for the ugly URL. So instead of the URL above, the URL might be:
That way, a visitor can type in the pretty URL and load your website without ever even knowing that the ugly URL was actually used on the web server to generate the webpage.
Why are clean or "pretty" URLs important?
Pretty URLs are important for a few different reasons. The two most commonly cited reasons are the fact that pretty URLs are easier for users to remember and that search engines use the words in a URL as a clue about the subject matter covered by the webpage. It's also true that if someone is linking to you, the person browsing can get an idea of what the article is about. In addition, using pretty URLs makes it easier to make changes to the software powering your site without affecting your link structure.
Is mod_rewrite free?
Yes, mod_rewrite is a module of Apache, a completely free and open-source web server. Accessing mod_rewrite should not add any additional cost to your hosting plan.
How do I know if a host offers Apache?
The most common web server software stack includes a Linux operating system, Apache web server, MySQL database management system, and support for the PHP programming language -- a configuration referred to by the acronym LAMP. If you purchase hosting based on a LAMP stack, then you're getting an Apache web server. Look for the LAMP acronym while shopping for hosts or just ask the provider you're considering if their plans include Apache if that information isn't readily available.
Is mod_rewrite enabled on every Apache web server?
Mod_rewrite is an extension to the Apache web server. What that means is that it is not compiled into the web server by default. However, it is a free module and most hosts have it enabled.
Can I enable mod_rewrite on my shared hosting plan?
No. You need root access to the server in order to activate mod_rewrite. In addition, activating the module requires that you stop and restart the Apache web server, which is not something you can do as a user on a shared server. In other words, if mod_rewrite is supposed to be available but is not working on your shared server, you'll need to contact your host to have them troubleshoot the problem.
Can I enable mod_rewrite on my VPS or dedicated server?
Yes. If Apache is installed on your VPS or dedicated server you can activate mod_rewrite as long as you have root access to the server. You'll need to edit the Apache configuration file (httpd.conf) to do so and then restart Apache.
Is writing mod_rewrite rules hard to do?
Writing mod_rewrite rules by hand is a task best tackled by a qualified web developer. Thankfully, web applications that make use of mod_rewrite don't require you to write rules by hand. Instead, the application you use to power your website will write the necessary rules automatically. In other words, if you're using a web application like WordPress or Joomla, you can make use of mod_rewrite by adjusting the settings in the application itself without ever typing a single line of mod_rewrite code.
How do web applications send mod_rewrite instructions to Apache?
Web applications that power websites, such as WordPress and Joomla, send instructions to the mod_rewrite module by adding those instructions to an .htaccess file.
How can I view the mod_rewrite rules that apply to my website?
The .htaccess file that contains your site's mod_rewrite rules can be found in the root directory of your website. In addition to any mod_rewrite rules, it may also contain a variety of instructions for Apache. To identify the rules that apply to mod_rewrite, look for a line that says "IfModule mod_rewrite.c." The lines following this statement are your mod_rewrite rules. Don't make any changes to your site's .htaccess file unless you know what you're doing.
Can I use mod_rewrite with a different web server?
No, mod_rewrite is an Apache module, so you can only use it with Apache.
Do other web servers such as Nginx offer an alternative to mod_rewrite?
Yes. For example, try-files is the Nginx equivalent and URL Rewrite 1.1+ is the Microsoft IIS 7+ equivalent. All common web servers provide some mechanism to use "pretty" URLs.