.htaccess is a configuration file for use on web servers running Apache software. Usually all public hosting providers use Apache. You can take advantage of .htaccess by creating or changing this file in your “public_html†directory. Optimizing 404 errors with .htaccess Websites tend to lose content or change urls from time to time. Not working urls stays in google cache and when google bot crawls them they receive 404 not found error instead of 200 ok. It is better to avoid giving google and most of all your visitors, broken links. For example we recently removed “http://www.cheapseoservices.org/directory-submission-service/†from our website, but google has it listed and people may find it with keywords like: “cheap directory submission serviceâ€, so it is more convenient for the visitor if we redirect him to related or current services we are offering. We add this line to our .htaccess file: and create 404.php file in “public_html†404.php: This will redirect all our 404 not found pages to homepage, where user will be able to see what we currently offer. Google also sees this as a benefit, because we are making sure visitor is not left alone and he gets at least related information he was looking for. Enabling Gzip compression Gzip compression is a feature nowadays websites and browsers use to improve website load time. One of google ranking factors is page speed, so if you can, use this method. Most modern hosting providers have mod_gzip module running on their Apache. To enable gzip compression add this code to your .htaccess file: Forcing www. Technically urls “www.website.com†and “website.com†are duplicates and sometimes if you enter website url without “www.†you get an error. To avoid errors and inconvenience for the user, choose if you want to use www. or not and add this code to your .htaccess file: Creating SEO friendly URLS Instead of having urls like: â€www.mywebsite.com/index.php?page=contacts&id=9999″ it is better to use seo friendly urls like: “www.mywebsite.com/contacts/â€. SEO friendly urls are more convenient for the user, because he can easily indentify what is the website about, just by looking at the address bar. To create SEO friendly urls add this code to your .htaccess files: 301 permanently moved redirect for moved content Sometimes you have to change location of your content. For example "www.cheapseoservices.org/some-topic/" has to be changed to "www.cheapseoservices.org/some-topic-and-additional-features/". To avoid serving your visitors page not found errors, use this kind of code in your .htaccess file:
Thanks dealeris, you have mentioned an very important aspect of on page seo. having a proper redirection along with 404 not only makes a website useful for an SE but also to a visitors. Its a really great share.
I was looking this days for something similar... now I am glad that I have found exactly what I need. Thank you
Here are six htacccess tricks which will help improve the security and Seo quality of your WordPress-powered website 1. Canonical robots.txt 2. Canonical Favicons 3. Canonical Sitemaps 4. Canonical Category, Tag & Search URLs 5. Canonical Feeds 6. Simpler Login URL The .htaccess code in this post is designed to work when placed in the web-accessible root .htaccess file of your domain. Before making any changes to this file...
To be fair, the www vs. no www situation should really be handled by the DNS configuration via a CNAME. If it's not, you should question your provider's DNS implementation. The rest of the suggestions are excellent. Great post!
wow..thanks a lot to dealeris for sharing this ht.access file important and how it is very useful for Search Engine Results Pages...keep it up.
Worth considering the point made here before redirecting 404's to the homepage Also info @ G Support recommending not to redirect to homepage
While it does work, the traffic has to hit the DNS server, then the web server, then the .htaccess file, and then be converted for the page to load, whereas if you do it in DNS like it should be it's DNS server, web server, page loads. Much faster.