HTML/<base href >/PHP question:
Overview:
http://a.com/parent.php PHP-includes
http://a.com/include.html
http://b.com/parent.php PHP-includes
http://a.com/include.html
http://a.com/include.html contains relative <img> links within a.com
a.com and b.com are separate hosting accounts, separate domain names, but by design have a similar parallel directory structure
Details:
I have two separate web sites of which i'm the designer of each and I have full control.
There is a portion of one page (similar/parallel on each site) that has a PHP include that includes an html file, and the text works fine-- it displays in both contexts.
However, there is an image reference in the html code that has a *relative* <img> link - of course, it only displays on the web site URL where the jpeg file resides. (temporarily i've duplicated the jpeg files in both hosting accounts just to get the project going)
The included html file (and associated images) changes each week, and the updating/editing of that weekly change is sometimes cut and paste and sometime manually entered in a WYSIWYG script web-based html editor. Thus it's not as easy as just making the image reference to be an absolute link. I do not do this weekly update (my client does this, and is not computer savvy)
I'm looking for a way to accomplish the function of base href for a given scope (i.e., the scope of just the include file)-- i could live with the scope starting at the point of the include and remaining in effect for the rest of the parent file (after the include input stream returns to the parent).
I can only find that base href is allowed in the html header and is effective for the entire page.
i would rather not do frames (since the "parent" web page is complex in itself with masthead and sidebar nav menus, etc)
Another constraint is that PHP is set on our servers to not execute code across URLs. the home path needs to be where it's called from. Thus i chose the include to reference an html file type so PHP would be able to include across domain names (hosting accounts).
Thus this rules out setting a PHP variable that is then concatenated to provide an absolute directory path. or putting code in to reference environment vars to "repair" the link.
It's not efficient/reliable to hope that however the file is edited each week it will copy the image files to the parallel site's corresponding directory location.
any thoughts on how to accomplish displaying the images within the included html file?
thanks
will
{HOSTNAME}
where the hostname goes - then its a simple - no possible problems str_ireplace -
(would do that before I woud do the first - as the first - you got the possibility of it being src="http://image" or src='http://image' or src=http://image