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 >> |