background preloader

Htaccess

Facebook Twitter

A Deeper Look at mod_rewrite for Apache. Twice a month, we revisit some of our readers’ favorite posts from throughout the history of Nettuts+. This tutorial was first published last September. When people think of .htaccess configuration, the first thing that might pop into their minds is URL manipulation with mod_rewrite. But they're often frustrated by mod_rewrite's complexity. This tutorial will walk you through everything you need to know for the most common mod_rewrite tasks. Mod_rewrite Rants Thoughts on mod_rewrite vary quite a bit. Mldk: Aargh! Bsterzenbach: Man do I love mod_rewrite.

Mikemackay: Still loving the total flexibility of mod_rewrite - coming to the rescue again. Hostpc: I hate mod_rewrite. Awanderingmind: Oh Wordpress and Apache, how thou dost vex me. Danielishiding: Why won’t mod_rewrite work! A few things I noticed are that people clearly recognize the power of mod_rewrite, but are often frustrated by the syntax. Despite the tons of examples and docs, mod_rewrite is voodoo. What a turn off! URL vs. Syntax. Making sure .htaccess is ok Apache Web Server forum at WebmasterWorld. The 'before' part in the headers report is the request from Firefox to your server. The 'after' part is the response from your server. Unless you're dealing with pages that change on every request, secure pages used for logging into accounts, or ErrorDocuments, then basically everything else should be cacheable.

Images and media files the longest, because they're least likely to change, .css and .js in the middle range (not likely to change frequently on a mature site), and pages should be cached for shorter times -- a day or two max, in most cases. "Public" means to allow caching in public (network) caches, like those used by AOL and Earthlink at the 'borders' of their networks. "Private" means browser and other end-client caches. If you change your content depending on the requesting user agent (e.g.

IE versus everyone else), then the benefit of public caching is reduced. Posting on this forum modifies the pipe character, making them show as "¦" broken pipes. Jim. 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. This can be done either by uncommenting the appropriate lines in the Configuration file, or using the -enable-module=expires and -enable-module=headers arguments to configure (1.3 or greater). Apache .htaccess caching code ^ # 1 YEAR <FilesMatch "\. Caching Concepts ^ What is Cacheable?