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?


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 5 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 5 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004