I am wondering what primers/guides/tutorials/etc. are out there for learning to rewrite URLs using Apache/.htaccess? Where is a good place to start?
My primary interest is learning how to point certain directories to others, and how to use portions of a URL as parameters to a script (i.e. "/some/subdirs/like/this" => "script.php?a=some&b=subdirs&c=like&d=this").
Source: Tips4all
I found this to be pretty useful: http://www.addedbytes.com/apache/url-rewriting-for-beginners/
ReplyDeleteI would go straight to the horse's mouth:
ReplyDeletehttp://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
but as a gentler introduction:
http://www.workingwith.me.uk/articles/scripting/mod_rewrite
The Apache Documentation site has a good introduction to using mod_rewrite.
ReplyDeleteIt covers how the directive works and has quite a few examples, eg:
RewriteRule ^/games.* /usr/local/games/web
RewriteRule ^/product/(.*)/view$ /var/web/productdb/$1
It coveres everything from the basic sytanx for changing the URI (which is what you seemed to be asking about) as well as using regular expressions, conditions and responding with redirects.
The apache documents have always been useful to me. O'Reilly's Apache: The Definitive Guide is also a good physical resource.
What's wrong with the manual?
ReplyDeleteThe Apache manual has lots of examples.
ReplyDeleteURL Rewriting Guide
URL Rewriting Guide - Advanced topics