What is mod rewrite?

Back to cheatsheet

mod_rewrite is a module for the Apache Webserver that performs rewriting http requests. mod rewrite modifies the Uniform Resource Locators (URL) to an internal oder external target (forward).

This process is called URL rewriting. The software component that performs the URL rewriting is called rewrite engine. In general Rewrite engines are part of a webserver or a web application framework.

Url rewriting enables to provide search engine friendly URLs (SEF-URL) independent of the underlying software. SEF-URLs look more relevant and human readable. The rewrite engine maps the external SEF-URLs to software specific internal URLs.


A typical usecase are permalinks in Wordpress. By default the permalink URL a page about dog habbits may look like:


There are two mayor benefits of an URL like


For SEO the URL of an article should contain it's major keywords, because the URL is an indicator for the page content. This indicator is not only useful for search engines but also for humans.

Links of interest

  • http://httpd.apache.org/docs/current/mod/mod_rewrite.html
  • https://wiki.ubuntuusers.de/Apache/mod_rewrite/
  • https://en.wikipedia.org/wiki/Rewrite_engine