possible to share images between Virtual Hosts?

Problems with the Windows version of XAMPP, questions, comments, and anything related.

possible to share images between Virtual Hosts?

Postby bjh » 26. April 2020 03:46

I have set up two Virtual Host's named "A" and "B". I plan to use "B" as a testing site and was wondering if it is possible for "B" to access the images folder on "A" rather then having to having to copy over the images from "A" to "B"?
bjh
 
Posts: 13
Joined: 24. April 2020 06:06
XAMPP version: 7.4.4
Operating System: Windows 10 Pro 1909 64-bit

Re: possible to share images between Virtual Hosts?

Postby Altrea » 26. April 2020 07:38

Sure, you could simply configure an Alias for that images folder.
https://httpd.apache.org/docs/2.4/mod/m ... html#alias
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11934
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: possible to share images between Virtual Hosts?

Postby Nobbie » 26. April 2020 11:55

You also can use a symolic link from folder A to folder B (this works as well for Windows as for Linux). Activate "FollowSymlinks" in Apache Configuration.
You also may use the same DocumentRoot for both VirtualHosts, or embed one DocumentRoot under the other.
Or simply link all images to VirtualHost A, even in context of VirtualHost B.
Or redirect from image folder A to image folder in B (use relative links in HTML Scripts).
Or use URL rewrite, or or or.

There are sooo many solutions.
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04

Re: possible to share images between Virtual Hosts?

Postby bjh » 26. April 2020 23:33

Thanks for the suggestion. Took a while but got finally got the Alias to work. Anyone know how to use the php file_exists() function on an alias directory? I had it set up to show a "Photo coming soon" GIF if the file wasn't found. Once I managed to get the Alias working and a hard coded picture to show up on the page, I changed it back to getting the pictures name from the database and now every picture is the "Photo coming soon". I'm guessing I'm passing in the wrong path for the images to the file_exists() function.
bjh
 
Posts: 13
Joined: 24. April 2020 06:06
XAMPP version: 7.4.4
Operating System: Windows 10 Pro 1909 64-bit

Re: possible to share images between Virtual Hosts?

Postby Nobbie » 27. April 2020 08:49

You have to pass the physical filename to file_exists. Like c:/xampp/htdocs/images/mypicture.jpg or so
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 197 guests