|Refer to folder outside domain|
I have inherited some websites which all use the same webspace which is divided into folders.
The overall webspace is referred to by say www.abc.com and there is a folder inside this which is referred to by say www.123.com
abc.com has a folder called photos whose contents can obviously be easily referred to by pages in abc.com using /photos/mypic.jpg
My problem is that I want to refer to images in the photos folder from www.123.com.
I can do it using www.abc.com/photos/mypic.jpg but I'd rather use some form of relative addressing if possible, can this be done?
I am using php if that helps.
Not enough information. What kind of hosting service (shared, dedicated, VPS, etc.) and what web server (Apache, IIS, etc.) are you using?
Assuming Apache, are you able to modify Apache configuration files, or are you restricted to using .htaccess?
How is one domain being redirected to the other? Using server redirects, via a third-party (registrar, etc.) redirect site (sometimes erroneously called "DNS redirect"), framed redirect, etc?
How you do this is going to depend on the details of your server configuration.
The best way to do this would be to set-up multiple virtual hosts. Disk directories that have content that is in common between sites can be mapped from multiple hosts, using the same or different URL paths.
I am using shared hosting on an Apache server.
I don't have access to the config files, but I can use .htaccess.
I am with 1and1, I'm not using any redirects or framing, their Name Servers point to folders within my webspace.
|I'm not using any redirects or framing, their Name Servers point to folders within my webspace. |
So, if somebody goes to www.123.com, they are going to see the home page for www.abc.com? Does some PHP code customize the HTML text, so that it shows the appropriate site name? In any case, if you are doing this, the browser's URL bar is going to show the wrong site.
Or is www.123.com a completely separate site with it's own host/hosting plan?
If the former, it's ot a good way to do this at all - you are making do with a hosting plan that really isn't suited for this. It's an SEO nightmare.
If your goal is just to simplify addressing within your documents, you might want to look at the HTML <BASE> tag. This will allow you to reference documents from another part of your site, or even another site altogether, in a relative fashion.
It's rather limited, though, in that it sets a base for all references made from a page.
Just to be clear, the DNS servers point the domains to the server's IP address, as DNS servers always do.
It is the server configuration that defines these "add-on" domains as subfolders below your "main domain" filespace.
One way to do this is to use symbolic links in the add-on domains' filespace -- these links make it appear that there is a virtual 'copy' of the shared folders/files in each domain's filespace.
Another way to do it is to use "Aliases" for the shared folder names, but this requires more control over the server configuration than is allowed by most "control panels."
Sorry, I'm unfamiliar with 1&1's hosting plans, but just took a look. I gather that they do support virtual hosts. So, it's not just a matter of the DNS server pointing to different subdirectories.
Yes, a symbolic link could do the job, if you have access to a shell login in order to create one.
Otherwise, you can use an .htaccess redirect.
Thanks for your help.
Sorry if I wasn't clear, I'm quite new to all this.
I think I will end up using full urls for the images that are outside the domain.