开发者

HTML Base Equivalent in .htaccess?

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.开发者_StackOverflow社区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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜