background preloader

Apache

Facebook Twitter

Speed Up Sites with htaccess Caching. This article shows 2 awesome ways to implement caching on your website using Apache .htaccess (httpd.conf) files on the Apache Web Server. Both methods are extremely simple to set up and will dramatically speed up your site! iFModule for fail-safe .htaccess ^ At least one of the 2 modules needs to be built into Apache; although they are included in the distribution, they are not turned on by default. To find out if the modules are enabled in your server, find the httpd binary and run httpd -l; this should print a list of the available modules. The modules we're looking for are mod_expires and mod_headers. If they aren't available, and you have administrative access, you can recompile Apache to include them. <ifModule mod_expires.c> # any Expires Directives go here </ifModule><ifModule mod_headers.c> # any Header directives go here </ifModule> Apache .htaccess caching code ^ # 1 YEAR <FilesMatch "\.

Caching Concepts ^ Caching with mod_expires ^ mod_expires Caching ex. 1 ^ What is Cacheable? How to use RewriteCond to ignore some folders. This code will not do what you expect, because the first rule will match anything the second rule might match. RewriteRule ^(.*)/$ test1.php? Url=$1 [L]RewriteRule ^(.*)/(.*)/$ test2.php? Url=$1&id=$2 [L] Remember that the pattern ". *" will match any number of any characters, including the slash that separates your two directory levels. Therefore, the second rule will never be evaluated or run, and test2.php will never be activated. In addition, using ". *" can be very inefficient when two or more such subpatterns are present, as mod_rewrite will have to evaluate the string from both ends to figure out how to divide the string between the two subpatterns. I'd suggest: RewriteRule ^([^/]+)/$ test1.php?

Jim. Drupal Performance Tuning and Optimization for large web sites | 2bits.com, Inc. - Drupal Development, Customization and Consulting. Apache Mod-Rewrite. Mod_rewrite Cheat Sheet (V2) - Apache - Added Bytes. The second version of the mod_rewrite Cheat Sheet, a quick reference guide for mod_rewrite, with rewrite flags, regular expression syntax and sample rules. Get It Today! Including: - Rewrite flags - Regular expression syntax - Sample rules Buy Now - Pay What You Like! (the average paid so far is $2.12.) Overview The mod_rewrite cheat sheet is a one-page reference sheet, listing flags for the RewriteRule and RewriteCond directives, list of server variables, a regular expression guide and several examples of common rules. If you're new to URL rewriting with mod_rewrite, you might find my article on URL Rewriting for Beginners useful.

What's New? There are a few small changes from the first version of the mod_rewrite Cheat Sheet (which you can still download if you prefer). Regular Expression Syntax URL Rewriting with mod_rewrite depends a great deal upon a solid knowledge and understanding of regular expressions. RewriteRule and RewriteCond Flags Redirection Header Codes Example Rules Directives. .htaccess tricks and tips.. part two: url rewriting with mod rewrite. Corz.org uses cookies to remember that you've seen this notice explaining that corz.org uses cookies, okay!

<ifModule> more clever stuff here </ifModule> redirecting and rewriting "The great thing about mod_rewrite is it gives you all the configurability and flexibility of Sendmail. The downside to mod_rewrite is that it gives you all the configurability and flexibility of Sendmail. " - Brian Behlendorf, Apache Group One of the more powerful tricks of the .htaccess hacker is the ability to rewrite URLs. This enables us to do some mighty manipulations on our links; useful stuff like transforming Very Long URL's into Short, Cute URLs, transforming dynamic ? Generated=page&URL's into /friendly/flat/links, redirect missing pages, preventing hot-linking, performing automatic language translation, and much, much more. Make no mistake, mod_rewrite is complex. Very little here is my own invention. RewriteRule (.*)\.htm $1.php beginning rewriting.. simple rewriting.