I need some help with some advanced file include code.. I googled around, but I’m not sure how to describe it in a short way for searching.
Basically here is the file structure:
/public_html/include_handle.php
/protected_site/index.html
/images/image.jpg
If I include index.html using a regular include statement, image.jpg obviously won’t show in the browser because it’s not in a public/relative directory. Short of some heavy preg_match/replace parsing, how can I get the image to show on the include_handle.php page when including index.html? I would also like to be able to follow links to other pages from the index.html page. I know I can use iframes and put the static pages in a public directory, but I don’t want that for various reasons. Any help would be greatly appreciated, Thanks!
You can use the base HTML tag for your page to work as if it was in a different directory (or host). Relative links will be resolved using this value as the current document.
I guess
protected_siteis not accessible from the web. You will need a PHP script to read the files from the protected directory and send them to the user. It will look something like:If you don’t want to change the content of index.html and still link to images as
something.jpginstead of the above, you can use mod_rewrite on the server side:This way apache will call your PHP for any image files which do not exist in the public directory.