htaccss is used to manipulate URLS on Apache web servers.
As we all know, URLs are a tremendously important factor in SEO, and the easiest way to improve them is htaccess.
here is a simple example for htaccss file. The file we have is called /aboutthecompany.html but we want out viewer to see a clean path – /about/
Options All -Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^about?$ ?aboutthecompany.html [L]
That was simple, here are some more tricky examples:
Zen-cart product pages urls usually look like
/index.php?main_page=product_info&products_id=7
how powerfull would it be if we could auomatically change them to look like
/gemstones/7/Aquamarine-Round-Blue
here is an htaccss file that will do exactly this:
Options All -Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^gemstones/(.+)/(.+)/?$ index.php?main_page=product_info&products_id=$1 [L]
isn’t that nice?
another nice example is changing the url of images
instead of /images/1212121212.jpg
we’ll see /gemstones-images/1212121212/Ligh-Blue-Aquamarine
Options All -Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^gemstones-images/(.+)/(.+)?$ images/$1.jpg [L]
and this example shows how to redirect all the gemalaya.com traffic to www.gemalaya.com
Options All -Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^gemstones/(.+)/(.+)/?$ index.php?main_page=product_info&products_id=$1 [L]
RewriteCond %{HTTP_HOST} ^gemalaya\.com$ [NC]
RewriteRule ^(.*)$ http://www.gemalaya.com/$1 [R=301,L]
Isn’t that cool?
all the examples above can be seen live on Gemalaya Loose gemstones
Outstanding info. Thanks so much. I’ve read several of your posts on moving website without losing ranking. Extremely helpful stuff. Thanks a million!