Quick and Easy .htaccess tricks
First, and I say it first because it is the most important thing I’ll say at all, BACKUP your .htaccess file if you already have one.
Check with your server host as to whether or not you already have an .htaccess file. It is usually found in the root of your site directory. However, some ftp applications cannot see it because it is consider to be a ‘hidden’ file. There’s a reason for that.
Before doing anything, check to see if you have this file. Also, if you edit this file on your computer and then upload it back up to your host server, be sure to select an ASCII transfer, not binary – which is usually the default.
A better way to do this is to edit the file ON the server.
Either way, BACKUP THIS FILE NOW!
~~~~~~~~
Did you backup your .htaccess file, yet? Ok, I’ll wait.
~~~~~~~~
Ok, it really is that important. If you make a mistake in this file, it can bring down your entire web site. And I mean DOWN.
So, on we go. This is really not so much a how-to but more a link-to. There are times when I run across something that’s just good. No need for imrovement. This is one of those times.
I edit my .htaccess file so little that I really don’t need to take the time to learn how to do it. I just have to know where to find the required information.
When it comes to editing my site’s htaccess file, this is the only information I need: htaccess tips and tricks.
One edit I make on every site is a redirect for traffic that arrives on the non-www version of the url. For example: kimmergeek.com vs www.kimmergeek.com – the latter being what I am after. Here’s how that’s done:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
This snippet will take any page that is requested with a non-www version of the url, change the url to the www. version, AND tell Google this is a permanent change. This flags the google sipder-bot to update the index with the preferred url version.
Why is this important? Because Google sees kimmergeek.com and www.kimmergeek.com as 2 different sites. Two different sites with identical content – NOT good in Google’s eyes.
Did I mention you really should backup your file before you edit it?