Redirect www to non-www URLs
If you want redirect users from www to a plain, non-www domain, insert this configuration in your .htaccess file: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] [...]
Redirect non-www to www URLs
If you want redirect users from a plain, non-www domain to a www domain, insert this configuration in your .htaccess file: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\. [NC] [...]
Redirect an entire site with .htaccess but exclude one or more directories
We recently wanted to move a website to a new domain and automatically send visitors and Googlebot to the new content, but certain resources had to remain on the current domain. This meant [...]
Using a domain name instead of localhost with XAMPP, WAMP or MAMP
With XAMPP (Windows) Locate your hosts file. In Windows XP, this file is located in C:\WINDOWS\system32\drivers\etc. Different versions of Windows may store the file in a different directory. And [...]
Apache – Enable Keep-Alive
Enabling keep-alive tells the browser of your visitors to establish a TCP connection once instead of multiple times to request all the web files loaded on your web page (like images, CSS [...]
403 Forbidden Error and Solutions
Error code that start with 4xx is generated because of client browser request. A 403 error code means client browser (or person who is trying to access your site) cannot access the requested URL. [...]
Apache 2.4 – RewriteRule Flags
This document discusses the flags which are available to the RewriteRule directive, providing detailed explanations and examples. Introduction A RewriteRule can have its behavior modified by one [...]
Disable Browser Caching with .htaccess
Quick .htaccess snippet to disable browser caching by modifying Cache-Control, Pragma, and Expires headers. Strictly plug-n-play. Just add the following directives to your site’s root .htaccess [...]
Redirect non-www URLs to www
# Redirect non-www URLs to www RewriteCond %{HTTP_HOST} !^www.domain.tld$ [NC] RewriteRule ^(.*)$ http://www.domain.tld/$1 [R=301,L]