Home arrow Search Optimization arrow htaccess SEO and Security Tips
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement

htaccess SEO and Security Tips


(Page 1 of 2 )

This is a beginner's guide to htaccess. It is meant to introduce this configuration file and its useful implementations in website management. .htaccess is a server configuration file commonly found in Apache, Zeus and Sun Java System web servers. It provides a lot of applications with implications for website security and search engine optimization. You cannot find or use .htaccess in Microsoft-based IIS servers and non-Apache-based servers.

To create and upload an htaccess file:

1. Open any text editor (such as geditor in Ubuntu or notepad in Windows).

2. Enter the htaccess syntax you would like to implement on your website (at the text file).

3. Save it as .htaccess

Note: There is a "." before the filename, and there is no file extension to it; just .htaccess

4. Upload it to a directory where you would like the directives to be implemented. An htaccess uploaded to the root directory of your website will cover all of the website's directories and files (from root to inner).

But if you upload only the .htaccess file to a specific inner directory, the directives on that .htaccess file can be only be implemented in that specific directory.

IMPORTANT: If you have an existing .htaccess in your website and you plan to edit it, it is extremely important to secure a backup of that .htaccess first, before doing anything else.

301 redirecting old/dead URL to new URL

Suppose you have URLs, and then you delete them because they are no longer needed. You need to replace them with new URLs (by re-publishing content, for example, or shortening your URLs).

With respect to SEO implementation, this approach can cause you to lose a lot of traffic and link juice, because those old URLs might be contributing a very significant amount of traffic and links to your website.

What is the best solution? Instead of giving those URLs a 404 header status (not found, or does not anymore exist), you need to 301 redirect those non-existing URLs to their new, permanent location.

With this method, if those dead URLs are still indexed by Google, any users coming from search engines or other websites can still read and visit the new URLs because they have been "301 redirected."

To do this, you can use .htaccess to do the 301 redirects. For example:

HTACCESS SYNTAX:

redirect 301 /2009/04/how-to-make-blogger-post-title-unique.html http://www.php-developer.org/how-to-make-blogger-post-title-unique/
redirect 301 /about/ http://www.php-developer.org/about-codexm/

There are two 301 redirection commands above; the first is to 301 redirect:

http://www.php-developer.org/2009/04/how-to-make-blogger-post-title-unique.html

TO:

http://www.php-developer.org/how-to-make-blogger-post-title-unique/

The second redirection is to 301 redirect:

http://www.php-developer.org/about/

TO:

http://www.php-developer.org/about-codexm/

What if you have a URL with spaces? For example: http://www.php-developer.org/wp-content/uploads/tutorials/Excel database functions sample sheets.xls

Then you will need to use a double quote in the 301 redirection line, e.g:

HTACCESS SYNTAX:

redirect 301 "/wp-content/uploads/tutorials/Excel database functions sample sheets.xls"  http://www.php-developer.org/excel-database-sample-sheets/

The above line will 301 redirect that URL with spaces to this new location: http://www.php-developer.org/excel-database-sample-sheets/

Note: 301 redirection implementations using .htaccess will be uploaded to the root directory of your website. If you have an existing .htaccess, you will simply need to edit it and add the redirection lines. You will not need to actually create a brand-new .htaccess. 

Disable hot linking to save website bandwidth

If you have a website in which you are hosting fairly large files like MP3s, video files and audio wave files, then someone outside your domain might be tempted to take advantage of your website's resources by directly streaming/linking to it, without paying a single penny for bandwidth use.

Why is this not good? Your website's bandwidth (for which you are paying with your hosting bills) is being substantially consumed by unauthorized persons. This is known as "bandwidth theft" and includes stealing pictures from your website by reusing them in another website (NOT in your website).

Abuse can slow down your site and weaken your website security. This is where you can use .htaccess to prevent this.

For example, say you want to prevent "hot linking" for the following file types mp3, jpg and wav audio files. You want to allow only your own domain (e.g yourdomain.org) to access them; other domains are restricted.

HTACCESS SYNTAX:

## DISABLE HOTLINKING
RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?yourdomain.org/.*$ [NC]
RewriteRule .(mp3|jpg|wav)$ - [F]

Again, if you upload the .htaccess file to the root directory of your website, all of your website directories and files will be protected against hot linking, as stated in your .htaccess file.

Adding more than one domain to hot link to your site

There are times when you have several websites and you need to hotlink to the images, perhaps for convenience and saving disk space. In this case, if you implemented the above .htaccess syntax, then your website will not be permitted to access those images.

You can grant permission to any website to access and "hot link" your web content (images, etc). For example:

HTACCESS SYNTAX:

## DISABLE HOTLINKING
RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?yourdomain.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?seochat.com/.*$ [NC]
RewriteRule .(mp3|jpg|wav)$ - [F]

The .htaccess lines above allow seochat.com to hot link to yourdomain.org website (in addition to yourdomain.org, of course).

More Search Optimization Articles
More By Codex-M

blog comments powered by Disqus

SEARCH OPTIMIZATION ARTICLES

- Write Content For the Four Buying Personalit...
- Write SEO Content for Your Visitor`s Goals
- Title Tags: Not Just for Keywords Anymore
- The Challenge of SEO for Large Enterprises
- Viral Writing: the Beauty of Controversy
- The 375 Million Active Searchers You`re Prob...
- A Closer Look at Crushing Local SEO Competit...
- Crushing Local SEO Competition: A Case Study
- More Ways to Get Attention For Your Blog
- Cosmetic Surgery Marketing: Inbound Marketin...
- Dominating Local SEO
- Local SEO: Secrets to Killing The Competition
- Scientific Results Of 23 Million Visits: Cre...
- Feed Your Blog`s Readers Well
- Laying Out An SEO and Traffic Generation Str...
 
SEO Chat Forums  
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Contact Us 
Site Map 
Request Media Kit
Write For Us Get Paid 
SEO Weekly Newsletter
 
SEO Tools
Adsense Calculator
AdSense Preview
Advanced Meta-Tags
Alexa Rank Tool
Check Server Headers
Class C Checker
Code to Text Ratio
CPM Calculator
Domain Age Check
Domain Typos
Future PageRank
Google Dance
Google Keywords
Google Search
Google Suggest
Google vs Yahoo
Indexed Pages
Keyword Cloud
Keyword Density
Keyword Difficulty
Keyword Optimizer
Keyword Position
Keyword Typos
Link Popularity
Link Price Calculator
Meta Analyzer
Meta Tag Generator
Multiple Link Popularity
Page Comparison
Page Size
PageRank Lookup
PageRank Search
Robots.txt Generator
ROI Calculator 
S.E. Comparison 
S.E. Keyword Position 
Site Link Analyzer 
Spider Simulator 
URL Redirect Check 
URL Rewriting 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 10 - Follow our Sitemap
Popular SEO Chat Topics
All Tutorials & Tools
 
SEO Chat is sponsored by:
Close this Sponsor Message