Reply
.htaccess with multiple sites - HELP!!
Old 06-12-2007, 12:08 PM .htaccess with multiple sites - HELP!!
Registered User

Posts: 24
Location: UK
Hi,

I've been struggling to find the answer to my question for days - can anyone help me - using simple terms PLEASE?


I have 4 domain names all on the same web host, 1 which is in the / directory I want to keep as is. I have another sub directory which has another index page in it, and my web host points my 3 other domains to it - so identicle content (at the time I thought it was a good idea to have a few domain names :-(

Well now I find out that duplicate sites / content is bad so I apparently need to 301 permanent redirect 2 of them.

There is lots of info on the web but none showing how to do it in my situation, ie the three domain names all pointing to the same index file.
I did find something that appeared to fit the bill and you can see it below
is it correct?

so do I just have to put that in the .htaccess file and put it next the the index file? and do it twice (once for each domain I want to redirect) in the same .htaccess file with a blank line in between?

Here's the code and the writing that was with it

REALLY appreciate any help you can give


If both olddomain and newdomain point to the same server filespace, then you will need to tell this rewrite rule not to redirect newdomain to itself, which it will do unless told otherwise.
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_HOST} !^www\.newdomain\.com
RewriteRule (.*)
http://www.newdomain.com/$1 [R=301,L]
The added RewriteCond prevent the rule from being applied unless the requested domain is NOT "www.newdomain.com"
onlineart is offline
Reply With Quote
View Public Profile Visit onlineart's homepage!
 
When You Register, These Ads Go Away!
Old 06-12-2007, 03:26 PM Re: .htaccess with multiple sites - HELP!!
Extreme Talker

Posts: 249
Location: Belgium, Antwerp, Zoersel
The code is correct. All you've got to do is put it in a .htaccess file which you put besides your index, but you do that only once. You don't need to do it more, I don't even know if it would still work if you did.

The "Options +FollowSymLinks" isn't needed for the redirection by the way. It's used to let the server know that it should threat symbolic links (in the filesystem) as if it were real files. You can safely remove it it you want.

Your .htaccess should look like:

Code:
RewriteEngine on 

RewriteCond %{HTTP_HOST} !^www\.newdomain\.com 
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

Last edited by Orodreth : 06-12-2007 at 03:32 PM.
Orodreth is offline
Reply With Quote
View Public Profile Visit Orodreth's homepage!
 
Reply     « Reply to .htaccess with multiple sites - HELP!!
 

Thread Tools

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 Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11492 seconds with 12 queries