Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-02-09 10:41:04

jens31
Plugin Author
From: munich / dtschermani
Registered: 2008-08-25
Posts: 183
Website

one site on two domains with some different content..

hi

id like to build two sites on two domains.
some elements, like the header for example should be different.
but all the content should be the same.

so it would be perfect for me
to build one site, check the url for the different elements
but load the content from one db.
is this possible?
keep in mind that the root domain would be variable, too. so there wouldnt be just one root domain, but two.

or would it be possible to mirror certain elements from one db..?

i dont know, some hints would be a pleasure.

best
jens

Offline

#2 2010-02-09 12:47:02

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: one site on two domains with some different content..

<txp:php>
    variable(array('name' => 'server_name', 'value' => $_SERVER['SERVER_NAME']));
</txp:php>
<txp:if_variable name="server_name" value="site1.org">
    <!-- items unique to site1.org -->
<txp:else />
    <!-- items unique to site2.org -->
</txp:if_variable>

Code is topiary

Offline

#3 2010-02-09 13:03:02

jens31
Plugin Author
From: munich / dtschermani
Registered: 2008-08-25
Posts: 183
Website

Re: one site on two domains with some different content..

looking good, thanks :)
ill try this out, asap.

but isnt txp also always redirecting to the site_url from the admin section..?

Offline

#4 2010-02-09 14:18:59

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: one site on two domains with some different content..

jens31 wrote:

but isnt txp also always redirecting to the site_url from the admin section..?

No, admin pages do not rely on the site URL pref.

However, the site_url tag obviously won’t work for this site. You could make a variable for the site URL and use that instead. Also, “View Site” and “Preview” links will go from the site URL pref. I can’t think of any other issues, but then I haven’t thought about it much ;)


Code is topiary

Offline

#5 2010-02-09 14:51:15

jens31
Plugin Author
From: munich / dtschermani
Registered: 2008-08-25
Posts: 183
Website

Re: one site on two domains with some different content..

aight, i also think, that this will work.
thanks for your help jsoo.

Offline

#6 2010-02-09 15:28:58

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: one site on two domains with some different content..

To be on the safe side, your server name comparison should be case insensitive, as:

variable(array('name' => 'server_name', 'value' => strtolower($_SERVER['SERVER_NAME'])));

then using lower case in the if_variable comparison (as in the previous example).


Code is topiary

Offline

#7 2010-04-29 08:59:46

geoff777
Plugin Author
From: Benarrabá Andalucía Spain
Registered: 2008-02-19
Posts: 282
Website

Re: one site on two domains with some different content..

Hi,

I want to do the same thing …

I have a txp install running with quite a lot of articles.

I’d like to set up a second domain (both are on the same server) exactly as in Jens31 original post.

Would someone who’s tried this give me a few clues as to how I do this.

Do I do I just copy the TXP install on domain1.com into domain2.com’s folder? Is it that easy …?

Thanks
Geoff

PS I’m not worried too much about SEO as 90% of the content is syndicated news and hardly original to my sites. :)

Last edited by geoff777 (2010-04-29 09:02:47)


There are 10 types of people in the world: those who understand binary, and those who don’t.

Offline

#8 2010-04-29 10:28:25

jens31
Plugin Author
From: munich / dtschermani
Registered: 2008-08-25
Posts: 183
Website

Re: one site on two domains with some different content..

hi geoff777

nope, you dont need no second install.
just point the second domain on exactly the same folder like the other one and everything works fine.
if you want to display different content (like different headers on each site) you can go with the code of jsoo. it works like a charm..

Offline

#9 2010-04-29 11:18:40

geoff777
Plugin Author
From: Benarrabá Andalucía Spain
Registered: 2008-02-19
Posts: 282
Website

Re: one site on two domains with some different content..

Wow even easier!

I love TXP

Thanks for the quick reply.

Geoff


There are 10 types of people in the world: those who understand binary, and those who don’t.

Offline

#10 2010-04-29 14:29:38

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: one site on two domains with some different content..

Hi jens31,

Could you please share the public URLs for both websites? I would like to have a sneak peek at end result :)
Thank you.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#11 2010-04-29 14:59:19

jens31
Plugin Author
From: munich / dtschermani
Registered: 2008-08-25
Posts: 183
Website

Re: one site on two domains with some different content..

for sheezy

http://blog.staatsoper.de/
http://blog.staatsballett.de/

same same, but different :)

Last edited by jens31 (2010-04-29 15:00:07)

Offline

#12 2010-04-29 19:05:34

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: one site on two domains with some different content..

Thanks, nice site, nice trick.

I may be back later asking a few more technical details, as I’m currently thinking a similar setup, but with a not so minor difference: there is www.domainA.com, and there is www.domainB.com, and I need the latter (which is just a single homepage, no subsections) to just be an alias (or a cloaking) for www.domainA.com/B-section.

So far, the “correct” way to do it seems to be using a Reverse Proxy, but I’m not sure yet if that’s possible on client’s hosting. Will have to investigate a little more.

(Of course, there are a few dirty solutions, like using an iframe…)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB