Forum Moderators: phranque

Message Too Old, No Replies

Multisite/Domains with 1 master htaccess file - 301 redirects

301 redirect setup on multiple domains/websites with one master htaccess fi

         

justincrabbe

6:58 pm on Aug 10, 2012 (gmt 0)

10+ Year Member



I have a multi-site setup in which I have one master htaccess file for 6 domains.

www.111.com through to www.666.com

Currently the setup is:

www.111.com/product1
www.222.com/product1
...
www.666.com/product1

I need to set-up specific redirects to preserve search engine indexing for each domain and break apart the urls essentially:

www.111.com/product1
www.222.com/newerproduct1
...
www.666.com/newestproduct1 for example...

ALL in the one file... And specific to each domain. About 600 redirects in total. 100 per site.

g1smd

9:19 pm on Aug 10, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



...and the problem is?

justincrabbe

10:17 pm on Aug 10, 2012 (gmt 0)

10+ Year Member



I need to setup 301 redirects for:

www.222.com/product1 redirects to www.222.com/newproduct1 URL.

and so on for each of the different domains (www.111.com through www.666.com) all in the same htaccess file.

Can this be done in the ONE master htaccess file even though all domains share the same htaccess?

It will look like this - keep in mind the same htaccess file and that there are specific 301's for different domains... 600 redirects in total. Notice below.


RewriteEngine On

## 301 Redirects
# 301 Redirect 1
RewriteCond %{HTTP_HOST} ^trueketones\.com$ [NC]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^raspberry-ketones-one-month-supply-p-57\.html$ [trueketones.com...] [R=301,NE,NC,L]

# 301 Redirect 2
RewriteCond %{HTTP_HOST} ^truecoffeebeanextract\.com$ [NC]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^green-coffee-bean-extract-one-month-supply-p-2\.html$ [truecoffeebeanextract.com...] [R=301,NE,NC,L]

g1smd

10:23 pm on Aug 10, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is this a ZenCart or osCommerce site, perchance?

Use example.com in this forum to suppress URL auto-linking.

justincrabbe

10:26 pm on Aug 10, 2012 (gmt 0)

10+ Year Member



Will do re example.com..

Yes. all zen carts. Zen cart multisite.

lucy24

1:47 am on Aug 11, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is there any overlap in page titles? Say,

www.example.com/foobar/pagetitle.html
AND
www.example.org/foobar/pagetitle.html

where the rule has to apply to only one? If not, it's a non-problem because any request for a given page title will also be a request for the appropriate domain. And if some human does goof, heck, why not redirect 'em right along with the correctly entered requests?

Is there a functional reason why everything has to share an htaccess? On a smaller scale: I've got two domains in the same userspace. They have a shared htaccess for core-level "Deny from..." directives and a few other things. Each one has its own htaccess for site-specific stuff. There is no overlap in modules. That is, mod_rewrite happens only in the site-specific htaccess, mod_setenvif happens only in the shared one, and so on.

justincrabbe

1:06 am on Aug 12, 2012 (gmt 0)

10+ Year Member



Yes the same titles and URL"s for all 6 multisite domains.

I now need to seperate and preserve search engine rankings with the 301 redirects.

It would be good to have dynamic htaccess files for each of the six websites but I dont think this is possible...

Is there an issue with having muliple "sets" of URL redirects in the same htaccess file like the above example? Essentially each site will have 100 product page redirects. Times six websites/urls is 600 redirects in ONE htaccess file. They are specific page redirects and therefore will include the actual full URL in the redirect. Like above.

lucy24

3:28 am on Aug 12, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes the same titles and URL's for all 6 multisite domains.

Oh, wait. Wasn't there a similar question just a few days ago? I think that one only involved two domains. But the principle was that

www.example.com/foobar.html >> www.example.com/widget.html
AND
www.example.org/foobar.html >> www.example.org/widget.html

That is, the path part of the redirect was the same, but each had to stay in its own domain. And you can't just cheat by using /widget.html as the target, because that won't get your domain name into canonical form.

Is that what you've got here? Or will
www.example.com/foobar.html
AND
www.example.org/foobar.html
each be redirected to a different filename?

If so, I don't see much alternative to having every single one of your 600 redirects come with a preceding Condition checking for domain, like

RewriteCond %{HTTP_HOST} example\.org
RewriteRule widget\.html http://www.example.org/pageone.html [R=301,L]

RewriteCond %{HTTP_HOST} example\.com
RewriteRule widget\.html http://www.example.com/pagetwo.html [R=301,L]

and so on. A new one for each Rule, because Conditions belong to one rule.

It would be good to have dynamic htaccess files for each of the six websites but I dont think this is possible...

What do you mean by "dynamic" and why isn't it possible? It's true that in general you want to put your rules as high up the (physical) filepath as possible-- but this isn't "in general". Here I think you would save a lot of time and resources if everything domain-specific went in the htaccess for that domain alone. For starters, you'd be able to throw away 600 lines of identical RewriteCond.

You can't put <Directory> envelopes in an htaccess. You might be able to do something with FilesMatch, but frankly I've never got it to behave properly when matching anywhere but the far right (end of name).

justincrabbe

4:26 am on Aug 12, 2012 (gmt 0)

10+ Year Member



This is what i have here:

www.example1.com/triptorelin-5mg to www.example1.com/triptorelin-5mg-package

www.example2.net/triptorelin-5mg to www.example2.net/triptorelin-5mg-kit

www.example3.ca/triptorelin-5mg to www.example3.ca/triptorelin-5mg-take-home-version

www.example4.info/triptorelin-5mg to www.example4.info/triptorelin-5mg-high-quality

And so on. For the 6 different domains.

We're dividing out the zen cart multisite to have UNIQUE product pages for each of the multisites and wish to preserve search engine rankings ...

Currently the zen cart multisite module will only show duplicate content across all the multiple sites. All product and category pages are shared between all sites.

We've just got hit for duplicate content and 5 of the 6 pages dropped off Google page 1.

phranque

8:51 am on Aug 12, 2012 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



each of your RewriteRules will require a preceding RewriteCond testing the HTTP_HOST environment variable in order to capture the domain name and tld so that can be used to target the canonical hostname in the RewriteRule.

lucy24

10:01 am on Aug 12, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I said that.

:: whine ::

But is your example part of a pattern? That is, do you also have

www.example1.com/viagra-5mg to www.example1.com/viagra-5mg-package
www.example2.net/viagra-5mg to www.example2.net/viagra-5mg-kit

www.example1.com/cialis-5mg to www.example1.com/cialis-5mg-package
www.example2.net/cialis-5mg to www.example2.net/cialis-5mg-kit

and so on? If so, you will at least be able to make composite rules that look like

RewriteCond %{HTTP_HOST} www\.example\.org
RewriteRule (overpricedpharma1|overpricedpharma2|overpricedpharma3) http://www.example.org/$1-package [R=301,L]

RewriteCond %{HTTP_HOST} www\.example\.net
RewriteRule (overpricedpharma1|overpricedpharma2|overpricedpharma3) http://www.example.net/$1-kit [R=301,L]

That will save you some repetition.

justincrabbe

12:45 pm on Aug 12, 2012 (gmt 0)

10+ Year Member



No there is no pattern. Were completely breaking apart each of the product pages with their own content and URL. Every URL will be unique.....?

g1smd

4:54 pm on Aug 12, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



www.example1.com/triptorelin-5mg to www.example1.com/triptorelin-5mg-package

www.example2.net/triptorelin-5mg to www.example2.net/triptorelin-5mg-kit


What happens when
www.example2.com/triptorelin-5mg-package
or
www.example1.net/triptorelin-5mg-kit
is requested?

What about non-www requests for both old and new URLs? Where should they redirect to?

You'll need very careful planning before putting the fixes live.

justincrabbe

6:23 pm on Aug 12, 2012 (gmt 0)

10+ Year Member



I was thinking duplicating each of the redirects for non www. entries. 1 with www and the other without www..

Because the URL's in your example are different and they are the new proposed URL's, you'll finally see unique content on each.

One category/product is for one site, the other category/product is for the other site in the multisite network...

Naturally, Zen Cart multisite will share categories and products across sites in the multisite network. We're now breaking everything apart. Instead of one category and one product for all 6 sites we now have SIX categories and SIX products with all different names, titles, and therefore URL's.

So we need to 301 from the original native 'master' url's to the new url's for the broken out categories/products with unique content on each.