Computer Forums

Computer Forums (http://www.geekboards.com/forums/index.php)
-   Building Websites (http://www.geekboards.com/forums/forumdisplay.php?f=3)
-   -   Better Search Engine Optimization with Mod_Rewrite (http://www.geekboards.com/forums/showthread.php?t=229)

sjaguar13 05-06-2006 07:12 PM

Better Search Engine Optimization with Mod_Rewrite
 
Google sees www.YourSite.com, YourSite.com, YourSite.com/index.php, and www.YourSite.com/index.php as four different sites. The problem is that when your PageRank is split up into fourths, none of them will actually gain good results. Using mod_rewrite you can change all non-www URLs into www.

First create a .htaccess file (or edit the one you already have). You need to add the following code:
Code:

Options +FollowSymlinks All -Indexes
rewriteEngine on
rewriteBase /
RewriteCond %{HTTP_HOST} ^yoursite.com$
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=301,L]

What this does will do is tell the rewriteEngine to start looking for any incoming host that does not have the www. in front. You need to change yoursite.com to your actually domain. The it will add the www. for you. It checks to see if any other files were added, like yoursite.com/page1.php. If there was, it will add the www. in the front and also put the page1.php at the end. The R=301 says the redirection is a permanent one. This is the key for Google. It will ban you for having duplicate content, so doing a temporary redirect, a 302, isn't a good idea. Google could think that the page that's doing the redirection has the same content as the one it gets redirected to. The L says it's the last rule, don't bother looking for anymore and just redirect already.

I use this on almost all of my sites and my PR has been climbing ever since.


All times are GMT -5. The time now is 08:40 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
HTML Help provided by HTML Help Central.