Forum Moderators: phranque

Message Too Old, No Replies

Links to files outside DocumentRoot

         

tntpower

4:06 pm on Sep 25, 2008 (gmt 0)

10+ Year Member



My main site (www.example.com) DocumentRoot is

/var/www/html

there is a folder /var/www/html/abc

Now I need to setup a virtual host (www.example2.com) that uses /var/www/html/abc as its DocumentRoot

The problem is that for many files in /var/www/html/abc, their links are based on main site's DocumentRoot, as during development, we do not expect /abc will be DocumentRoot for a virtual host

For example, in about.html at /var/www/html/abc, it may has an image like

<a href="/images/hello.jog">Image</a>

/image here refers to /var/www/html/image

Now, when visitors go to www.example2.com, I want them to see the image as well, without requiring me to copy /var/www/html/image to /var/www/html/abc or to change all such links in all files in /foo

Any idea?

Thanks

raffles

4:17 pm on Sep 25, 2008 (gmt 0)

10+ Year Member



absolute links would solve the issue here instead of relative

raffles

4:20 pm on Sep 25, 2008 (gmt 0)

10+ Year Member



or use server side includes

encyclo

4:49 pm on Sep 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can either use the filesystem (assuming you're on Linux/Unix) and create a symlink:

ln -s /var/www/html/image /var/www/html/abc/image

Alternatively you can modify the Apache configuration and use an Alias [httpd.apache.org].

The final, and often best, option is not to have one site within the document root of the other at all. You can create extra domains or subdomains within /home, for example - then you can set aliases for shared files for each domain.

tntpower

8:32 pm on Sep 25, 2008 (gmt 0)

10+ Year Member



Hi raffles and encyclo, thank you.

To use alias will work, but does not resolve all problems. While I can set alias for "image", that only applies for situations that I know them in advance.

I am looking for a solution that web server will first try to find a file in this site's Documentroot, if not found , then go to main site's documentroot to find.