Mod rewrite Tutorials

overview - syntax - basic - medium - advanced

Mod Rewrite Overview

We're hearing more and more about mod rewrite every day. E commerce applications are making add-ons to their software to allow for it, content mangement systems are using it and most of all blogs are taking it to the next level as they are now becoming more and more popular.

So what is mod rewrite, what can it do and how can I use it to further the opimization of my website?

Mod rewrite is just one of the many modules that are tacked on to the Apache webserver. It's main purpose is to detect incoming uri request (file name) and rewrite them to a redirect or to an alias file.

What does mod_rewrite really rewrite?

First lets start off by killing the implied meaning of a mod rewrite.

  • A mod rewrite DOES NOT rewrite the url in the browser. A mod rewrite is not a magical url changer. You cannot flip a switch and hope to change all your dynamic urls to static urls.
  • A mod rewrite does it's rewriting on the server AFTER a file has been requested.

In this sample below we're telling the mod rewrite that if the file called file_name.htm is request that it should be rewritten to its alias file_name.php.

Rewrite Sample: RewriteRule ^file_name.htm /file_name.php [L]

SEOs use mod rewrite more as a translator. An SEO can instruct his web developer to out put clean urls for a dynamic application and then by using mod rewrite translate those clean urls back to it's dynamic form on the server.

In this example the mod rewrite is looking for the directory named mod/rewrite/tutorial/ it is then going to make three references () and then call those references and rewrite the folder to it's alias some_file.php?name=mod_rewrite_tutorial

Rewrite Sample: #rule to rewrite /mod/rewrite/tutorial/ to it's dynamic
#query string some_file.php?name=mod_rewrite_tutorial
RewriteRule ^(mod)/(rewrite)/(tutorial)/ /some_file.php?name=$1_$2_$3 [L]

So lets dig in and start learning the mod rewrite syntax.

Mod Rewrite Overviw :: Mod Rewrite Syntax >>

Questions that are answered here:

  • What is a mod rewrite?
  • What can a mod rewrite do?
  • How do I rewrite my messy urls
  • How do I make clean urls

On Page Resources

  1. Mod Rewrite - One of the many modules for the Apache web server. Uses regular expressions to detect and rewrite urls in real time.

  2. Apache Modules - List of moduldes that can be added or come with apache 1.3.

  3. Apache Server - Most popular web server used.

  4. Alias file - An alias or a proxy file is a file that is called to take the place of a requested uri. Most of the time the requested uri is a folder or file that does not exist on the server. For example we can say read index.htm (which doesn't exist as a real file) as index.php that does exist on the server.

  5. Dynamic url - A url that passes variables using the GET method. These variables are visible in the web browser and can be seen in the url. They follow any file or folder name and start with a ? and can use a & sign to denote a second, third variable and so on.
    Sample: file.php?var1=mod&var2=rewrite

  6. Static url - A file name and folder passed through the web browser.
    Sample: /mod-rewrite/index.php

  7. SEO - Acronymn for search engine optimiz(er/ation).

 

Mod Rewrite (Home) | Mod Rewrite Tutorials | Directory | Code Library | Blog | Mod Rewrite Quick Guide

copyright © 2001 - 2010 Webforgers.net
Owned By SEO Uncloaked, LLC
Aggressive Search Engine Optimization
All rights reserved.