John Cox

Blogs · @wyome

Tagged htaccess · everything

5 .htaccess Snippets to Borrow from HTML5 Boilerplate

This article demonstrates practical .htaccess configurations from HTML5 Boilerplate that improve website security, performance, and functionality, including blocking hidden files, compressing files by MIME type, enabling cross-domain access for fonts and images via CORS, and setting browser cache expiration times for different file types. The author emphasizes that these server-side optimizations—particularly gzip compression and long cache expiration on static assets—provide significant performance benefits with minimal code overhead.

Permalink

Useful .htaccess Snippets

This article provides practical .htaccess code snippets for common web administration tasks, ranging from access control and security (password protection, blocking bots and referrers, hotlink prevention) to performance optimization (file compression, caching) and functionality adjustments (redirects to HTTPS, custom index pages, upload limits). Each snippet includes explanation of what it does and how to customize it for specific needs, making it a quick reference guide for implementing .htaccess rules without needing to understand the underlying Apache syntax deeply.

Permalink

.htaccess Files for the Rest of Us | Nettuts+

.htaccess files are plain text configuration files used to customize Apache web server behavior at the directory level, and this guide covers their practical applications including URL rewriting and redirects for SEO purposes, custom error pages, password protection, IP blocking, browser rendering control, caching optimization, and content compression. The article explains that .htaccess files are read on every server request so changes take immediate effect without server restart, making them useful when direct access to the main configuration file isn't available, though they do incur a minor performance cost. Each use case is illustrated with code examples showing how to implement common tasks like converting query strings into friendly URLs, serving custom 404 pages, and setting far-future expiration headers to improve site load times.

Permalink

17 Useful Htaccess Tricks and Tips

This article presents 17 practical .htaccess techniques divided into general optimization methods and security hardening measures. The general section covers tasks like setting timezone, implementing SEO-friendly redirects, file compression, and caching strategies, while the security section focuses on preventing malicious attacks through hotlink protection, blocking suspicious URL patterns, restricting access to sensitive files, and filtering unwanted bots and referrers. The author claims to have tested these methods and presents them as both essential security protections and efficiency improvements for web server management.

Permalink