Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-21-2006, 01:15 AM
WebProWorld New Member
 

Join Date: Apr 2006
Location: USA
Posts: 4
Stratcat RepRank 0
Default Where to add redirect code in .htaccess?

This is a newbie question:

I've read a lot about adding 301 redirect code to the .htaccess file in order to fix the problem of search engines mistaking www and non-www domains as duplicate content.

For example - according to Google analytics - Google currently thinks I have 3 domains all with duplicate content:

mydomain.com
MyDomain.com (Each word capitalized)
www.mydomain.com

My question is, does it matter where in the .htaccess file you place the redirect code? Is there a proper order that the various directives need to be in?

The code I'm going to use is:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^mydomain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^MyDomain.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]

Do I have the code correct and should I place it somewhere at the top of the file, at the bottom, or somewhere in between?

Everything I've read - from the apache docs to various forums - all just say to add the lines of code. No one ever says where to place it.

Any help would be appreciated,
Dean
__________________
Back and Neck Pain Relief
Reply With Quote
  #2 (permalink)  
Old 04-26-2006, 01:21 PM
WebProWorld New Member
 

Join Date: Apr 2006
Location: USA
Posts: 4
Stratcat RepRank 0
Default

For the benefit of any other newbies out there who may read this post...

The answer is, no, it doesn't matter what order the directives are placed in the .htaccess file.

And the code I finally went with is:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*) http://www.example.com/$1 [R=301,L]
__________________
Back and Neck Pain Relief
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0