Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Avoid Absolute Urls when sharing images between domains? |
|
Author |
|
mike
Joined: 16 Sep 2011 Posts: 3
|
Posted: Mon 03 Oct '11 21:04 Post subject: Avoid Absolute Urls when sharing images between domains? |
|
|
Hi,
I would be most appreciative if somebody could advise me on whether or not Apache can be used to solve my following problem.
I have two PHP coded websites in my htdocs folder.
The first website is in a folder called "website1" and I have assigned "domainName1.com" to "website1".
The second website is in a folder called "website2" and I have assigned "domainName2.com" to "website2".
There are images within subdirectories in "website1" that must display in the web pages for "website2".
My problem is that "domainName2.com" cannot display the images because they are not relative to "website2". Although I am able to display the images via absolute urls, I do not want the absolute urls for the images located at "website1" to be displayed in the source code of the web pages for "website2" under "domainName2.com".
Summary:
The images located in "website1" display correctly in "website2" when I browse "website2" as follows:
http://127.0.0.1/website2/
The images located in "website1" do NOT display in "website2" when I browse "website2" as follows:
http://www.domainName2.com/
The images located in "website1" display correctly in "website2" pages when I browse "website2" as follows (on condition that I output/provide the absolute url path statements to the images located in "website1"):
http://www.domainName2.com
Question:
Absolute path statements are not an option for me. Is it possible to instruct Apache to serve the image files located in "website1" to the web pages for "website2" when I browse the site via "domainName2.com", where the images appear to be relative to domainName2.com but are in actual fact relative to domainName1.com?
My folder structure looks like this:
htdocs > website1
htdocs > website2
I hope that my request is not confusing.
I look forward to your response.
Many Thanks.
Regards,
Mike |
|
Back to top |
|
MichaelG72
Joined: 03 Oct 2011 Posts: 4 Location: Price, Utah
|
Posted: Tue 04 Oct '11 0:24 Post subject: Idea and Sugestion |
|
|
In the vhost area of your domain2.com use and alias to domain1.com's images this way there is a path mapping to the images you want to use in domain2 and there would be no need to use absolute urls.
IE:
<virtualhost *:80>
Servername domain2.com
Alias /imgiwant/ Path to img's you want in this domains context root.
</virtualhost>
This way your adding a context root in domain2.com were images are mapped to /imgiwant/
So when you right your code:
<img src=/imgiwant/xxxx.jpg"></img> should bring the images up that your are wanting to retrieve in domain2 without exposing or using the absolute url of those images.
I could be wrong but it's an idea I'm new to all this stuff too. |
|
Back to top |
|
|
|
|
|
|