Change content based on web host

D

David Segall

I have a web site, <http://profectus.com.au>, that I host on my own
office server. I have instructed my name server, ZoneEdit
<http://zoneedit.com>, to use a backup location
<http://profectus.asia> that is hosted at <http://000webhost.com> if
my server is not available. I would like to make some minor changes to
the text on some pages depending on which site is being viewed. How
could I do this in HTML/CSS? If I can't, how could I do it with
client-side scripting? Server-side scripting is not currently possible
on either host.
 
J

Jonathan N. Little

David said:
I have a web site, <http://profectus.com.au>, that I host on my own
office server. I have instructed my name server, ZoneEdit
<http://zoneedit.com>, to use a backup location
<http://profectus.asia> that is hosted at <http://000webhost.com> if
my server is not available. I would like to make some minor changes to
the text on some pages depending on which site is being viewed. How
could I do this in HTML/CSS?

Yes, have different HTML/CSS at http://profectus.com.au than at
http://profectus.asia!
If I can't, how could I do it with
client-side scripting?

Er...sort of and if JavaScript is disabled?
Server-side scripting is not currently possible
on either host.

This is how it should be done.
 
A

Adrienne Boswell

I have a web site, <http://profectus.com.au>, that I host on my own
office server. I have instructed my name server, ZoneEdit
<http://zoneedit.com>, to use a backup location
<http://profectus.asia> that is hosted at <http://000webhost.com> if
my server is not available. I would like to make some minor changes to
the text on some pages depending on which site is being viewed. How
could I do this in HTML/CSS? If I can't, how could I do it with
client-side scripting? Server-side scripting is not currently possible
on either host.

Actually, 000webhost.com does have PHP and MySQL, so server side scripting
is available. Adding server side scripting to your own office server is
simply a matter of installing the necessary files.
 
D

David Segall

Jonathan N. Little said:
Yes, have different HTML/CSS at http://profectus.com.au than at
http://profectus.asia!

That's how I do it now but it would be _much_ more convenient if I
could use the same source code for both sites.
Er...sort of and if JavaScript is disabled?

I can accept that. The required changes are fairly trivial and if they
don't work for some visitors the worst that will happen is that they
will get a 404 page. Giving them a tailored 404 page was going to be
my next question :)
This is how it should be done.

Server-side scripting is, at least, an order of magnitude more complex
than serving HTML and drastically reduces the number of available
hosts especially free ones. I don't think it "should be done" unless
it is really necessary.
 
D

David Segall

Adrienne Boswell said:
Actually, 000webhost.com does have PHP and MySQL, so server side scripting
is available. Adding server side scripting to your own office server is
simply a matter of installing the necessary files.

Thanks Adrienne. The "possible" on both servers is currently limited
by the programmer, that's me, rather than the installed software.
 
J

Jonathan N. Little

David said:
Server-side scripting is, at least, an order of magnitude more complex
than serving HTML

Not more complex then HTML + JavaScript. Your comparison was server vs
client side scripting.
and drastically reduces the number of available
hosts especially free ones.

Was an issue in the 90's not so much any more.
I don't think it "should be done" unless
it is really necessary.

Yes that is how it "should be done" if what you are doing is adjusting
content. Clients side is not to be relied upon for page generation it is
optional being that it *is* client side and therefore do not have
control over its availability, whereas server side is under your control
and is "invisible" to the client.
 
J

Jonathan N. Little

David said:
Thanks Adrienne. The "possible" on both servers is currently limited
by the programmer, that's me, rather than the installed software.

<?php
$myServer = ( $_SERVER['SERVER_NAME'] == 'profectus.com.au' );

if( $myServer ) {
// set all stuff that your want specific to your server
$logo = 'OurComLogo.jpg';
$style = 'OurDefault.css';
...
}
else {
// set all stuff that your want for your backup server

$logo = 'OurAsiaLogo.jpg';
$style = 'OurAlternate.css';
...
}

....

<div id="header"><img src="<?php echo $logo; ?>" alt="Profectus"> ...
 
N

Neredbojias

I have a web site, <http://profectus.com.au>, that I host on my own
office server. I have instructed my name server, ZoneEdit
<http://zoneedit.com>, to use a backup location
<http://profectus.asia> that is hosted at <http://000webhost.com> if
my server is not available. I would like to make some minor changes
to the text on some pages depending on which site is being viewed.
How could I do this in HTML/CSS? If I can't, how could I do it with
client-side scripting? Server-side scripting is not currently
possible on either host.

Using javascript you can read the variable "location.href" and use
"indexOf" to (for instance) check for either "zoneedit" or "profectus".
Based on said conditional, impliment or make changes accordingly.
 
D

David Segall

Jonathan N. Little said:

[code snipped]

Thanks Jonathan but there are a few languages that I have carefully
avoided and PHP ranks high among them. If the application warranted it
I would pay for a Tomcat server rather than use the free PHP with
000Webhost. Your code was a fairly accurate reflection of the trivial
changes I wanted.
 
R

Raymond Schmit

Jonathan N. Little said:

[code snipped]

Thanks Jonathan but there are a few languages that I have carefully
avoided and PHP ranks high among them. If the application warranted it
I would pay for a Tomcat server rather than use the free PHP with
000Webhost. Your code was a fairly accurate reflection of the trivial
changes I wanted.

There a a lot of free webhosting different than webhost having the php
module usable. Personally i used php to make web pages different per
host. - and this can avoid the call for a visit counter when the host
is localhost.
 
A

Adrienne Boswell

Gazing into my crystal ball I observed David Segall
Jonathan N. Little said:

[code snipped]

Thanks Jonathan but there are a few languages that I have carefully
avoided and PHP ranks high among them. If the application warranted it
I would pay for a Tomcat server rather than use the free PHP with
000Webhost. Your code was a fairly accurate reflection of the trivial
changes I wanted.

Why would you avoid PHP? It's pretty easy to learn, and popular. I can
see wanting to avoid ASP.net, but why PHP?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top