View Full Version : Site within a site???

02-16-2009, 03:18 PM
Hello. Here's my dilemma...

I have a site hosted with no PHP/MySQL capabilities (let's call that www.siteA.com). Then I have another site hosted that does have PHP/MySQL capabilities (let's call that www.siteB.com). I'd like a way to masquerade it so that when a user goes to www.siteA.com, they actually are seeing and navigating through www.siteB.com. The URL in their address bar will not ever change from "www.siteA.com". I would build siteA's site pages in some directory on my siteB's server, and then just point it over to siteA somehow...

Would an iframe do this? Or would that be obvious when you're in siteA that you're looking at another frame? I want this to be as seamless as possible. Also, I'd prefer to not to a re-direct, because I want siteA's URL to stay in the user's address bar. Please let me know if this is possible. Thanks!...

02-16-2009, 03:41 PM
In your case an iframe would be your best solution, I think. You can make it look quite good.

In the css of site A, set your body to have a margin of 0 px. Your iframe obviously needs a width and height of 100%, and a border-style set to none.


<body style="margin:0px;">

<iframe src="http://www.codingforums.com" width="100%" height="100%" style="border-style:none;"></iframe>


It looks quite seamless. Of course, when looking at the source you can see you are in fact on another page. Reloading the browser window also poses a problem: you are redirected to the original page in the iframe. If you go to another page in site B (the one loaded into the iframe) and you reload the browser, you are redirected to site B's homepage.

But apart from that, I think it's the best option you have to achieve what you want.

02-16-2009, 04:07 PM
Awesome - that's exactly what I needed. Thanks! I kinda figured that the problems you mentioned would arise, but (as you said) it's my best option...

Much appreciated for the code to get me started. :thumbsup:

02-16-2009, 04:19 PM
Wait a minute - I spoke too soon. I'm not sure that worked...

Here's what happened. Here's the original site (Site B - with the PHP):


Here's the new site (Site A - with the iFrame):


I only looked in Firefox and IE7, but both of them only have about an inch or two of the iframe displayed. Like, it's not stretching down the whole page to cover the entire site that the iFrame is in...

02-16-2009, 04:38 PM
Sorry, my bad, in CSS you have to set the height of html and body as well in order for it to work.

So, in the page with your iframe:

<html style="height:100%;">


<body style="margin:0px;height:100%;">

Can't test it at the moment, so see if that works!

02-16-2009, 04:58 PM
Worked like a charm - thanks!!!

02-16-2009, 05:05 PM
No worries!

Heh, I'm gonna post solutions with errors everytime now if that gets me an extra thanks. :p

02-16-2009, 05:27 PM
No worries!

Heh, I'm gonna post solutions with errors everytime now if that gets me an extra thanks. :p

Haha - I thought about that after I did my second "thanks". Oh well!

02-16-2009, 05:33 PM
I posted quite some solutions on these forums already without ever getting a thanks for it (not even a reply), so as compensation for all of that I feel I'm entitled to this one. :thumbsup: