Apache Code Snippets

24 October, 2016   

You should NOT use this if you are ACTUALLY using WordPress.

29 July, 2015   

Apache code example shows how to remove .php from URL

Example Apache .htaccess file to add access control header

05 November, 2013   

Apache code example to limit access by IP address

As an example, here we are redirecting http://www.yoursite.com/product.php?id=231&category=seo to http://www.yoursite.com/seo/newpage.htm

23 February, 2013   

Some super-simple rules to kick out automated script.

23 February, 2013   

This is a really generic Not-WWW to WWW configuration script.

Optimize your website loading time by compressing files into smaller size.

Usually when you try to download something from a web server you get a request asking whether you want to save the file or open it. To avoid that you can use the below code on your .htaccess file

Example code for Force Favicon Requests to Correct Location

This code is useful for multi environment setups (staging, production, etc.) it allows you to keep your htaccess files in sync while maintaining an htpasswd on your development environment or anything but the live environment.

Normally index.html or index.php is the default page a server serves up when visiting a directory without specifying a file name. You can change this with .htaccess:

07 July, 2012   

Custom Error Pages by .htaccess file

You should use err_headers_out() and not headers_out() when you want to send cookies in the REDIRECT response.

08 June, 2011   

Did you know that search engine crawlers think that 'www.yoursite.com' and 'yoursite.com' are two different websites!? We need to help the crawlers out and tell them that the two URLs are the same. We can do this with a 301 (moved permanently) redirect. The code below will redirect requests for 'yoursite.com' to 'www.yoursite.com .