1

My first post here...I hope that I don't brake any rules and if I do please go easy on me :-) I have a page a.php with a simple form with one field: name

User puts his/her name and submits. File b.php is in the action field of the form and so it gets the form.

b.php needs to load a slideshow depending on the user input. Let's say there is a folder "clients" and it has folders John and Mary. Each of these folders will have an index file and other sub folders of images, CSS, JS, etc. The index files have relative paths to the subfolders like: ./images/pic1.jpg ./display.css etc.

Here is my problem: I want to load, say John/index.html without changing the URL that would be xyz.com/b.php If I use an iFrame the source code will show that xyz.com/clients/John/index.html is loaded and if I use PHP include("xyz.com/clients/John/index.html") then the relative paths that are in the John/index.html won't work.

I am trying to hide the physical location of the slideshow so I can always serve them under the same URL as far as the user can see. Changing relative paths to absolute won't work because that will give away everything that I am trying to hide!

I have simplified the form, folder name, etc. to explain the problem. Could anybody suggest any solutions please.

Rasul
  • 203
  • 1
  • 2
  • 12
  • see http://stackoverflow.com/questions/136458/change-the-url-in-the-browser-without-loading-the-new-page-using-javascript – Gabriel Santos Apr 08 '12 at 03:08
  • 1
    In a way or another your relative URL will be exposed, so is better your think in another way to hide its contents. Think if a user right click a image from the slide show and select "Open image in another tab", you absolute path will be exposed. So, if you are trying to hide it for security reasons, is better to show images through a PHP proxy (a script which will receive a parameter and output the correct image). – sergiogarciadev Apr 08 '12 at 03:11
  • Or a `image.php?file=fileHash` which get the image from correct folder. – Gabriel Santos Apr 08 '12 at 03:16
  • Gabriel, could you expand on your solution please. I have programming background, but I am new to PHP so things that might be obvious to a pro php coder don't click right away for me :-( – Rasul Apr 08 '12 at 04:36
  • @Sergio could you possibly give an example as how a script can output an image without referring to the image's location. Thank you. – Rasul Apr 08 '12 at 05:07
  • This tutorial should be what you need. http://foundationphp.com/tutorials/image_proxy.php – sergiogarciadev Apr 08 '12 at 21:26
  • Thank you @SergioGarcia for a very good read. The more I learn the PHP the more I love it. Can somebody pinch me...or better yet: let me be in my dream a little more :-) One side question: how do you rate a comment here? I can see numbers next to some comments and am assuming they indicate the usefulness of the comments, but can't find a way of adding anything of my own. Thank you again. – Rasul Apr 09 '12 at 02:04
  • @Rasul you can hate comments as soon as you get reputation, for vote up you must 15 reputation points. Check your privilegies here http://stackoverflow.com/privileges – sergiogarciadev Apr 09 '12 at 04:04
  • Hey, I didn't know that I had to have a reputation to _hate_ something, but I'll wait anyway :-) – Rasul Apr 09 '12 at 04:41

1 Answers1

2

I don't fully understand the question but <base> may help. It tells the browser to make all links from a page relative to another URL instead of where the page was loaded from

<base href="http://mydomain.com/mybaseurl/" />
Juan Mendes
  • 80,964
  • 26
  • 138
  • 189
  • Juan, thank you and it helps the situation although it doesn't entirely solve my problem of hiding the location of files. It seems like the actual solution might be what Sergio and Gabriel have suggested. – Rasul Apr 08 '12 at 04:58