Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2010-05-04 07:46:22

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..

A problem with using jsoo’s code.

If someone comes to your site using http://www.yoursite.com the variable server_name has a value=“www.yoursite.com”.

If another visitor uses http://yoursite.com the variable server_name has a value=“yoursite.com”.

So some conditional statements testing the variable will fail.

Either www. needs adding or stripping … or use an OR in your <txp smd_if …

I haven’t had my Weetabix yet or ten cups of strong coffee … so I’ll leave that problem for a proper PHP programmer.

I’m also having a problem with the wrong URL in my permalinks.

Last edited by geoff777 (2010-05-04 07:59:32)


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

Offline

#14 2010-05-04 08:26:15

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

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

hi geoff

the code of jsoo works fine for me
with or without www

Offline

#15 2010-05-04 08:56:47

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..

Strange I did test by changing the URL and outputting the variable.

I’ll do it again to confirm.

I’ve just tested it again and I’m getting different values … perhaps its a server issue? php.ini? .htaccess?

For now I’m working around it using Stef’s <txp:smd_if .. using operator=“in”

Last edited by geoff777 (2010-05-04 11:28:39)


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

Offline

#16 2010-05-04 19:32:36

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

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

geoff777 wrote:

perhaps its a server issue? php.ini? .htaccess?

Don’t know, but this should solve it (untested):

variable(array('name' => 'server_name', 'value' => strtolower(preg_replace('/^www\./i', '', $_SERVER['SERVER_NAME']))));

Code is topiary

Offline

#17 2010-05-05 10:26:39

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..

Jsoo,

That works perfectly.

Many thanks

Geoff


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

Offline

#18 2010-05-07 13:21:21

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..

I’d like to know about the traffic for each site.

I’ve been playing with the txp_log table – I’ve added a field to the end called server_name.

In log.php I’ve added the ‘server_name’ line below the ‘method’ line.

$out['method'] = serverSet('REQUEST_METHOD');
$out['server_name'] = variable(array('name' => 'server_name', 'value' => strtolower(preg_replace('/^www\./i', '', $_SERVER['SERVER_NAME']))));

Then in the safe insert at the bottom of the file … I added server_name=’$server_name’ at the end.

safe_insert("txp_log", "`time`=now(),page='$uri',ip='$ip',host='$host',refer='$ref',status='$status',method='$method',server_name='$server_name'");

I felt confident it would work, which was foolish because ..
a) it doesn’t
b) my php never does.

Any help would be appreciated.

Last edited by geoff777 (2010-05-07 13:38:55)


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

Offline

#19 2010-05-07 17:36:05

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

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

variable() doesn’t return anything when its value argument is set. You could just do:

$out['server_name'] = $_SERVER['SERVER_NAME'];

Code is topiary

Offline

#20 2010-05-07 20:00:42

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

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

@jsoo,

Although I’m still investigating variants, I would like to know if you have any trick under your sleeves to serve a particular TXP section from a different domain. This second domain will be just a “one-page” website, it will not need to serve any section.

To be more precise:

Main TXP site:
http://www.domain-A.com

which has a particular section:

http://www.domain-A.com/domain-B-section/

THen, I would like to have another domain (domain-B) serving the content from that section:

http://www.domain-B.com displays content from http://www.domain-A.com/domain-B-section/

——

I’ve investigated the possibilities and this are the options I’ve found:

  • the “pro” way: Reverse Proxy with Apache, if I’m not wrong. But this will highly depend on access to Apache configuration. So, let’s discard this for now, as this two domains are hosted on a Dreamhost account.
  • there is also the option to use a PHP Reverse Proxy, that as far as I understand, wouldn’t need any complex Apache trick, and this may be possible on a DH enviroment.
  • there is also the chance to “cloak” the domain using an iframe, but I would like to avoid this option and leave it as last resort.
  • maybe there is a way to “fake” Reverse Proxy by just having an script on www.domain-B.com that fetches the HTML from www.domain-A.com/domain-B-section and just simple serves that. Something like a wget, or curl, I think.

But if you have any better ideas about how to solve this situation, I will really appreciate that.
Thanks.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#21 2010-05-07 22:05:42

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

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

cURL ?


Code is topiary

Offline

#22 2010-05-07 22:15:24

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..

@jsoo

Thanks yet again :-)

Geoff


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

Offline

Board footer

Powered by FluxBB