Mod-Rewrite

Mod-rewrite is a module or plug-in for Apache servers. It enables you to rewrite or redirect URLs on a website. For this purpose, an unlimited number of rules can be defined within the module which control the rewriting of the dynamic URL. The module is also referred to as a rewrite engine.

Possibilities with mod-rewrite

With the module mod-rewrite, many server tasks or prerequisites for redirect tasks can be edited. The rules are filed in the .htaccess file. Umlaut handling is just one of the capabilities of mod-rewrite.

Here is a brief overview of common options:

Generating SEF URLs

Dynamic URLs can be rewritten using the rewrite engine in an SEO and user-friendly fashion.

Example:

Dynamic URL:

www.sample.com/kat.php?typ=wiki&typ2=seo

SEF URL after mod-rewrite:

www.sample.com/wiki/seo

Creating redirects to other URLs

As part of 301 redirects , it is ensured that only one website version arrives in the index of search engines.

Example:

http://sample.com

is permanently redirected to

http://www.sample.com

Exclusion of spam hits

Access by certain websites can be avoided by blocking predefined IP addresses.

Common rules

  • The following command switches the module on:

 RewriteEngine on

  • This is how a .php file can be output as .html:

 RewriteEngine on  RewriteRule ^(.*).html$1.php  => Rewrite all URLs with a php extension into URLs with html extension. Description of symbols:

 ^ Indicates the beginning of a URL  (.*) Is a placeholder for any character strings within a URL  $ At the end: the end of a URL  $ At the beginning: new string

  • This is how a dynamic URL is converted into a static URL:

 RewriteEngine on  RewriteRule ^page_ ([0-9] +).html$ page.php?id=$1  =>If a user retrieves page_5.html, this URL will be converted internally to page.php?id=5?. The result of this rewrite would be:

 www.domain.com/page_5.html 

turns into

 www.domain.com/php?id=5

rewritten.

More information on the syntax for mod-rewrite can also be found here: Apache modules mod-rewrite

Relevance to search engine optimization

As a general rule, dynamic URLs can be rewritten as “speaking” URLs using the mod-rewrite module. It is often discussed in SEO scene whether this manipulation of the URL can lead to better rankings. Proponents of this theory believe that the URL itself is a ranking factor. However, clear evidence to support this thesis in practice is lacking. Nevertheless, we can assume an indirect effect for search engine optimization because users can guess before clicking what kind of content can be expected from a SEF URL. Such a user-friendly URL accordingly serves to build confidence and also as a click stimulus. If an Internet user had a choice between a dynamic URL, (often seeming somewhat cryptic to laymen) and an optimized web address, they would probably tend to choose the latter.

Requests can be redirected with the rewrite module as well. SEOs often use this method to redirect permanently from keyword domains to the main website. The main website is supposed to be strengthened for a particular additional keyword that way. Redirects are often not considered relevant by search engines. In extreme cases, this practice is even interpreted as a manipulation of search results. If no other reason exists, for example, the short-term use of a catchy web address for advertising purposes, redirects should only be used to avoid duplicate content.

Web Links

Category

Related Articles