Top Search Result

  • about us
  • blog
  • online marketing
  • social network marketing
  • website creation
  • other resources
  • work portfolio
  • store
Home

SEO Using .Htaccess File For URL Rewrites

dawsonrb — March 30, 2009 - 7:46pm

Well this is a little geekier of a blog post then I would usually do but I had to do this for a couple of new real estate sites that I have been developing lately so I thought I'd share it with those who are interested.  Basically if you don't have this .htaccess setup, you are hurting your search engine results.

Google and other search engines will see your website with the WWW. and without the WWW. as two separate pages.  This splits your incoming link power and could raise duplicate content concerns.  You have to direct to either one or the other.  With or without the WWW. 

Please see video for further explanation. 

.htaccess URL Rewrite Example

This is my setup for using a Drupal site with the website being hosted on Bluehost.

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$">
  Order allow,deny
</FilesMatch>

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php

# Force simple error message for requests for non-existent favicon.ico.
<Files favicon.ico>
  # There is no end quote below, for compatibility with Apache 1.3.
  ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1.
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 4, Apache 2.
<IfModule sapi_apache2.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On

  # Cache all files for 2 weeks after access (A).
  ExpiresDefault A1209600

  # Do not cache dynamically generated pages.
  ExpiresByType text/html A1
</IfModule>

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # If your site can be accessed both with and without the 'www.' prefix, you
  # can use one of the following settings to redirect users to your preferred
  # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  #
  # To redirect all users to access the site WITH the 'www.' prefix,
  # (http://example.com/... will be redirected to http://www.example.com/...)
  # adapt and uncomment the following:
  RewriteCond %{HTTP_HOST} ^openhousespei\.com$ [NC]
  RewriteRule ^(.*)$ http://www.openhousespei.com/$1 [L,R=301]

  #
  # To redirect all users to access the site WITHOUT the 'www.' prefix,
  # (http://www.example.com/... will be redirected to http://example.com/...)
  # uncomment and adapt the following:
  # RewriteCond %{HTTP_HOST} ^www\executivewaterfrontpei\.com$ [NC]
  # RewriteRule ^(.*)$ http://executivewaterfrontpei.com/$1 [L,R=301]

  # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  # VirtualDocumentRoot and the rewrite rules are not working properly.
  # For example if your site is at http://example.com/drupal uncomment and
  # modify the following line:
  # RewriteBase /drupal
  #
  # If your site is running in a VirtualDocumentRoot at http://example.com/,
  # uncomment the following line:
  # RewriteBase /

  # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

# $Id: .htaccess,v 1.90.2.3 2008/12/10 20:04:08 goba Exp $

Bookmark/Search this post with:
  • Delicious Delicious
  • Digg Digg
  • StumbleUpon StumbleUpon
  • Facebook Facebook
  • Technorati Technorati
  • Search Engine Optimization
  • Delicious Delicious
  • Digg Digg
  • StumbleUpon StumbleUpon
  • Facebook Facebook
  • Technorati Technorati

Similar entries

  • Training
  • Website Down - Off And On
  • *STICKY - Link Exchanges - What and Why
  • 5 lessons I learned updating my website
  • RSS and Feedburner For Real Estate

Projects - Top Search Result

Skype Me&trade;!

TOLL FREE - 888-456-7904

Recent Blog Posts

  • Interesting Stats About Internet Affairs
  • Google Unleashes Multiple New Offerings
  • Mobile Marketing - Google Searching For Next Growth Area
  • Best Buy's Digital Marketing Stance
  • Facebook Is 4th Largest Coutnry In The World + Why It Matters To You
Syndicate content

Top Search Result on Facebook

Twitter Updates

    follow me on Twitter

    Top Search Result Is Certified By Google

    User login

    • Create new account
    • Request new password

    TOP SEARCH RESULT

    60 Hutchinson Crt.

    Charlottetown, PEI CANADA 

    1-888-456-7904 | 902-940-0140

    Serving: PEI, Moncton, and Halifax

    • about us
    • blog
    • online marketing
    • social network marketing
    • website creation
    • other resources
    • work portfolio
    • store