URL Rewriting Tool

Enter a URL



Popular Tools

Other Tools


About URL Rewriting Tool

Mod_rewrite - redirects for dynamic URLs

The mod_rewrite software module is the rewrite engine of the widely used Apache webserver. Rewrite engines like mod_rewrite allow to "rewrite" URLs, making them easier to read, for example, or even redirecting requests from specific URLs to another document.

Mod_rewrite: Clean URLs for dynamic websites

For example, mod_rewrite is used when the file hierarchy has changed and URLs need to be redirected. Such changes can be expected, for example, when switching from one content management system to another, or when optimizations and conversions are made to an existing CMS. A mod_rewrite rule ensures that visitors - including bots and search engine crawlers - get the correct document with the old URL. It also ensures that you do not have to edit hundreds of old blog posts so that links do not get lost. This application is also referred to as a permanent link or a shorter permalink.

Another purpose of mod_rewrite is the so-called clean URL, especially for dynamic websites. Dynamic websites are those that do not already have static documents but are based on user interactions, such as search queries or real-time data. Accordingly, the URLs of these pages also arise in real-time on the basis of user interactions; they have not linked anywhere on the website in this form. Often, these URLs are a concatenation of parameters passed to the server - not particularly readable to people.

In order to make these URLs more "talkative" and more manageable for humans, the so-called Clean URLs were created. So that they can be matched with the internal procedures of the servers, one needed a mechanism. Mod_rewrite is a powerful tool that can take over this function.

Mod_rewrite also allows sophisticated forwarding, for example on the basis of user agent identifiers, to be sent to specific browsers or devices with a customized version of the website, or based on the referencing website. With mod_rewrite, you can also prevent unwanted hotlinking of images, support the conversion of a static website in pure HTML to PHP, or redirect browser requests from non-existent documents to a 404 error page.

Building Rewrite Rules

Mod_rewrite rules are within a block beginning with "Rewrite Engine on" and ending with "Rewrite Engine off". Each rule consists at least of the "rewrite rule", which contains a schema, which mod_rewrite request is to be modified in what way. Optionally, "RewriteCond", which contains a condition under which mod_rewrite should rewrite the URL. Mod_rewrite Rules can either be stored in the .httpd file if they are to be domainweit, or in .htaccess files if they are only for one directory. Mod_rewrite rules "by hand" is not easy. Regular expressions are used in their creation, whose syntax can produce unexpected effects if one is not completely familiar with it. A flawed mod_rewrite rule can inadvertently make your site inaccessible to visitors.

The mod_rewrite generator for your website

That is why mod_rewrite generators are a very useful tool. If your site uses dynamic URLs, our mod_rewrite generator creates rules for you that you simply place in your .htaccess file in the root directory of your site on the server.