PCinvent.info

PCinvent Studio Template

May 08 2008
301 Redirection, Add www to the site URL Print E-mail
Thursday, 08 May 2008


Read More Articles in: Technology>>>Website

This Article is written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it


One of my sites had a problem on AJAX search while the user is typing the site without www, so I made a solution here.

here is the tips that you can always redirect all url requests to have www. as a fixed prefix by having .htaccess file in the site root.  Also, it is a good practice that search engine will treat the both url (with and without www) as the same. Hence, the spider process will go more smooth. (SEF)  ......

 

Create a file called ".htaccess" in site root.

Inside the file (change YourSiteUrl to your real URL):

Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\.YourSiteUrl\.com$ [NC]
RewriteRule !^blog(/.*)?$ http://www.YourSiteUrl%{REQUEST_URI} [R=301,L]

Now it should be prefect that when people type  YourSiteUrl.com or YourSiteUrl.com/somewebpage.htm, it will automatic redirect it and add www. to it in no time.

 

 

 

 

 

Comments (0)Add Comment

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley

busy
Tags:  Technology Website 301 Redirection Add www to the site URL Add www Redirect Redirect 301 moved permanently SEF
Last Updated ( Sunday, 18 May 2008 )
 
< Prev   Next >
Bluehost.com $6.95 Hosting
Site by PCinvent.com