Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.
Daily Diamond

301 Redirect for no-www to www

Status
Not open for further replies.

ArtfulWebSites

Level 3
Legacy Platinum Member
Joined
Nov 27, 2006
Messages
70
Reaction score
0
Ok, I have a virtual host account with one Primary Domain in the Root folder and several Secondary Domains in sub-folders.

For consolidation of Google Page Ranking and avoidance of any possible duplicate content problems with referrals to Domain.com vs www.Domain.com, I have made a master .htaccess file that I copy to EACH Domain's folder to 301 Redirect any reference to Domain.com to www.Domain.com.

It all works fine. I currently have it coded as:

RewriteEngine on
Options +ExecCGI
rewritecond %{http_host} ^Domain1.com [nc]
rewriterule ^(.*)$ http://www.Domain1.com/$1 [r=301,nc]

rewritecond %{http_host} ^Domain2.com [nc]
rewriterule ^(.*)$ http://www.Domain2.com/$1 [r=301,nc]

rewritecond %{http_host} ^Domain3.com [nc]
rewriterule ^(.*)$ http://www.Domain3.com/$1 [r=301,nc]
...Etc.

I suspect with the proper wild-card coding, I could consolidate the multiple redirect directives into one that would say "redirect [AnyDomain].com to www.[AnyDomain].com", but I am not sure how to code this correctly. Since all the sites are live, I don't want to screw it up.

Anyone out there know how to code that properly???
 
Register for the auction
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Members Online

Sedo - it.com Premiums

IT.com

Premium Members

AucDom
UKBackorder
Register for the auction
MariaBuy

Our Mods' Businesses

UrlPick.com

*the exceptional businesses of our esteemed moderators

Top Bottom