Question

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").

Was it helpful?

Solution

OTHER TIPS

I would go straight to the horse's mouth:

http://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.

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

The Apache manual has lots of examples.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top