Forum Moderators: phranque

Message Too Old, No Replies

Development server versus Production server

Need visual clue of what server I am looking at?

         

scraulb

9:06 pm on Aug 28, 2007 (gmt 0)

10+ Year Member



As I am getting old and stupid I would like to be able to tell from looking at my website if I am looking at my Development server (in my office) or my production server by looking at ANY page on ANY of my websites.

Can Apache be configured so that it outputs a <div> for every web page?

I have searched on this forum but cannot find anything related.

Thank You

g1smd

9:48 pm on Aug 28, 2007 (gmt 0)

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



I don't understand what the <div> would do.

I use dev.domain.com for development using a modified local HOSTS file to set that up, and www.domain.com for the real site in the normal way.

jdMorgan

9:49 pm on Aug 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you're using PHP, that should be easy to do: Just add the code as a PHP header. If you're not using PHP, you could use SSI and either include the div or exclude it depending on the value of HTTP_HOST.

Or you could get fancy and use either PHP or SSI to conditionally modify your CSS so that, for example, the background color of the dev pages is changed to yellow as a "warning", as opposed to the production server's normal page background color. Or modify some other obvious page attribute -- the possibilities are fairly extensive.

Jim

scraulb

9:51 pm on Aug 28, 2007 (gmt 0)

10+ Year Member



The <div> would contain a colored line or image depending on which server I am testing from.

I cannot use dev.mysite.com as all my links are hard coded to [mysite.com...]

scraulb

9:55 pm on Aug 28, 2007 (gmt 0)

10+ Year Member



So JD, there is no way to do it from Apache?

I am currently using php to detect the IP address (192.168.0.10). The trouble is that I am now getting 2 maybe three develpment servers and it would be nice not to have to put the php on every page (sites have about 100000 pages)

Cheers

g1smd

9:56 pm on Aug 28, 2007 (gmt 0)

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



Ah. All my links are coded like /folder/filename.html and all domain canonicalisation is done in the .htaccess file.

scraulb

10:02 pm on Aug 28, 2007 (gmt 0)

10+ Year Member



Ah... Smart.. I told you I was getting old and stupid.

To late to change now though.

jdMorgan

10:09 pm on Aug 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



add the code as a PHP header.

PHP has a function called "auto prepend headers" which will add a header to every page. All you have to do is turn it on.

Jim

scraulb

10:25 pm on Aug 28, 2007 (gmt 0)

10+ Year Member



Well.. I cant believe I did not know that!

I tried it and it works like a dream.

Thanks JD

g1smd

11:37 pm on Aug 28, 2007 (gmt 0)

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



It likely doesn't produce 100% valid HTML code as the add-on bit will appear before the opening !DOCTYPE and <HTML> tag in your HTML document.

However, as long as the add-on is only made to the development version of the site then there is nothing to worry about as far as indexing the public site goes.

scraulb

12:28 am on Aug 29, 2007 (gmt 0)

10+ Year Member



Yes.. Thats right.

In fact I put a DOCTYPE in the preappend on the development server so that my DIV sites would not break!