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").
In order for Apache to understand rewrite rules, we first need to activate mod_rewrite . It's already installed, but it's disabled on a default Apache installation. Use the a2enmod command to enable the module: sudo a2enmod rewrite.
A rewrite rule can be invoked in httpd. conf or in . htaccess . The path generated by a rewrite rule can include a query string, or can lead to internal sub-processing, external request redirection, or internal proxy throughput.
There are two main directive of this module: RewriteCond & RewriteRule . RewriteRule is used to rewrite the url as the name signifies if all the conditions defined in RewriteCond are matching. One or more RewriteCond can precede a RewriteRule directive.
I found this to be pretty useful: http://www.addedbytes.com/apache/url-rewriting-for-beginners/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With