Forum Moderators: open
1) content pages must be straight HTML and render correctly as straight HTML, including links and images
2) a PHP script collects up pages from various subdirectories into a big aggregate document
3) because I am deploying to two webservers, there is no common absolute path to use for links and images. So I have my local Macintosh/Apache server in which links reside under /localhost/~me/contentsubdir, and also a semipublic website (Linux/Apache, whew!) which is /subdomain.mydomain.com/ -- the URLs are very different
4) I don't want to have to munge my pages everytime I upload from my Mac to my webserver to change the absolute paths
5) I don't want to add PHP scripting to all of my content pages to get the images and links to render correctly
The problem is that right now, all the links and images from pages in subdirectories are bad relative paths, because they are relative to the subdirectory, whereas they are getting rendered in the enclosing directory.
I know exactly what directory each page is in and I have a URL converter that will work on it or on its enclosing directory, so if I could reset <BASE> before each file include, and clear it after, life would be easy.
But W3C seems to say <BASE> only works in the <HEAD> section.
Does anyone know equivalent alternatives? Anything that will 'relocate' relative paths in a subsection of HTML would be great.
I could run an edit on the files when I include them -- but I'd rather not
I could turn all the HTML files into PHP or SHTML files -- but I'd rather not
I could maybe set up a 404 handler that would catch the bad link and image references and turn them into the correct URLs... that wouldn't be so bad.
But again, the ideal solution would be a subsection-level <BASE> directive.
Any ideas?
Thanks in advance,
Andrew
/subfolder/section/page.html
may have an image reference "../graphics/image.jpg"
by which it means /subfolder/graphics/image.jpg
But when that page is being rendered from outside, e.g.
/subfolder/master.php?display=section/page.html
it presents the reference unchanged, which makes the browser ask for
/graphics/image.jpg
and that does not exist.
I'm seriously considering a 404 handler for this... I don't actually know that it will work, but it seems promising and it also seems like it would have zero impact on my pages.