troubleshooting Question

HTML base href PHP- desire to have a local scope for base href for images

Avatar of willsherwood
willsherwood asked on
5 Comments1 Solution319 ViewsLast Modified:
HTML/<base href >/PHP question:

Overview:   PHP-includes   PHP-includes    contains relative <img> links within and are separate hosting accounts, separate domain names, but by design have a similar parallel directory structure

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?

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros