views:

25

answers:

1

Let's say you have the following setup.

You have a server with the basepath set to the normal webroot.

The server has files in the following structure

/projects
    /some-unique-id
        /index.html
        /images
    /some-unique-id
        /index.html
        /images

Is it possible to have a .htaccess file somehow redirect the paths so if index.html has absolute paths they work.

For example if index.html contains /images/foo.gif can this magically become /projects/some-unique-id/images/foo.gif

The equivalent of the base html tag.

This is part of a CMS deliverable previewing system so I am restricted to not changing the HTML code.

Is there anyway to address this in an .htaccess file?

A: 

If each index.html contains <img src="/images/foo.gif"/>, the browser will request that URL and there will be no way for the server to know which page caused the request since the requests will be identical regardless of the originating page.

There is no way to do this with mod_rewrite unless you try to check the Referer header, which would be unreliable at best.

You will have to change your HTML markup to solve this. Using relative URLs seems like it would solve your problem.

Martin
After poking around I came to the same conclusion. Thanks for the detailed response!
booboobenny