Welcome to WebmasterWorld Guest from 54.226.133.245

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

rewriting domains and maintaining relative html references

     
8:19 pm on Jun 30, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 15, 2002
posts:450
votes: 0


Ok, here is an interesting question and one wonders whether it's possible to implement this using .htaccess files.

directory structure:

toplevel/graphics
toplevel/domainA/index.html

Now, you rewrite www.domainA.com to /toplevel/domainA, however, index.html uses relative URL's like this:

<img src="../graphics/">

My question is this: Can a rewrite be done so that the above rewrite can access the hierarchy above it even though the rewriteengine always rewrites domainA.com to that particular subdirectory?

6:21 am on July 1, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


scorpion,

Remember that the relative URL is a URL, not a filesystem path. When a relative URL is resolved to a canonical URL, it is the base URL that is used, not a server filepath.

So the answer is that using "../image" in your index file at [domain.com...] is not going to work, because you can't access a resource above your web root URL. But, since you don't need to, it doesn't matter.

I hope this is clear! Just remember that using mod_rewrite, YOU can make the rules of how URLs are mapped to the file system.

Jim

5:12 pm on July 1, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 15, 2002
posts:450
votes: 0


so essentially, there is no way to use relative urls and make it work?

Here is the problem:

You want a site that can be accessed one of two ways:

A) www.domainA.com
B) www.domainB.com/domainA

Both written to the same subdirectory however in the case of B) you can get away with relative URL's to the path above, with A) seems impossible.

So the solution is: use absolutes?

4:43 am on July 2, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


scorpion,

You don't have to do anything except use a transparent redirect from domainA/ to domainB/domainA/ and write all your links, relative or absolute, as if you are really in a separate, real domainA/ ... Since the redirect is always applied regardless of whether the link is relative or absolute, you don't have worry about anything. All requests for domainA/<anything> will get redirected to domainB/domainA/<anything>.

Now, if you want to have "shared" hosted images in domainB, which is above domainB/domainA, then what you'll need to do is to refer to those images as if they actually exist in domainA/ and then *not* redirect those requests so that they access files which are actually hosted in the root domainB directory. In order to keep this simple, I'd suggest a separate subdirectory of domainB to be used for these shared images.

As long as you are using transparent (internal) redirects. This ought to work just fine.

Jim