SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multiple Sites on same server - One Storage Location for Images?

    Hi, I'm new here not so much new to SitePoint but new to the forums. I have recently taken a new job and I'll be developing multiple sites based off of one database.

    I will have multiple websites pulling data from one database but what I would like is one site for creating the datasets. But I have a problem. At current I am storing images on a location on the web server when they are uploaded. I am currently only storing the end file name of the image in the database. ie(somefile.jpg).

    If I have say two different websites: http://websiteone.com and http://websitetwo.com

    I want to use the same images for both sites but not have them replicated multiple times on the server. Is there anyway I can make an image url of http://websiteone.com/images/products/sm/filename.jpg and http://websitetwo.com/images/products/sm/filename.jpg point to the same image using these urls?

    The websites are all stored on the same server in the following structure

    -www
    --public
    ---websiteone
    ----images
    -----products (virutal)
    ------sm (virtual)
    -------filename.jpg (virtual)
    ---websitetwo
    ----images
    -----products (virutal)
    ------sm (virtual)
    -------filename.jpg (virtual)
    --private
    ---data
    ----images
    -----products (actual)
    ------sm (actual)
    -------filename.jpg (actual)

  2. #2
    Visible Ninja bronze trophy
    JeffWalden's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,709
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    From what you explain, a few solutions come to mind, though you may not have the freedom to address them all given your requirements:

    1. Create a subdomain (or other domain) for image hosting: images.domain.com. Simply host all images on that subdomain site.

    2. You could rewrite the URL when requesting images. So if you store everything in /websiteone.com/images, place a .htaccess file in /websitetwo.com/images that rewrites any request back to /websiteone.com/images but requests that same file name, just change the path.

    3. You could store the images in the database rather than the filesystem, but I would recommend against this. For no other reason than it's more difficult (from my perspective) to manage and debug. I'm sure some SQL folks on here could argue this one.
    TAKE A WALK OUTSIDE YOUR MIND.

  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Or...just use hardlinks. Simple, let the underlying filesystem handle it.
    Or...depending on the server configure it to use a virtual directory that points to the real thing.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  4. #4
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JeffWalden View Post
    1. Create a subdomain (or other domain) for image hosting: images.domain.com. Simply host all images on that subdomain site.

    2. You could rewrite the URL when requesting images. So if you store everything in /websiteone.com/images, place a .htaccess file in /websitetwo.com/images that rewrites any request back to /websiteone.com/images but requests that same file name, just change the path.

    3. You could store the images in the database rather than the filesystem, but I would recommend against this. For no other reason than it's more difficult (from my perspective) to manage and debug. I'm sure some SQL folks on here could argue this one.
    #1 There is actually another link but I'd like it be on the intranet for extra safety. Though there is a possibility that it needs a public sub domain as well. Though I don't really want those links to show up as that.

    #2 How would I go about rewriting this rule? my .httaccess is rusty.

    #3 This doesn't seem like a good solution to me either. Seems like it would take query times up as multiple images will be used.

    Quote Originally Posted by logic_earth View Post
    Or...just use hardlinks. Simple, let the underlying filesystem handle it.
    Or...depending on the server configure it to use a virtual directory that points to the real thing.
    hardlinks? You mean actually write htttp://blahblah/images.jpg etc? They are already hard links The problem is I don't want the other websites to know about the dataset one.

    virtual directory - I will have to talk to my IT guy and ask him if this is possible, this might be the best solution if it's doable.

    Thank you both for your assistance it has given me some thoughts on where to continue looking.

  5. #5
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AWbab View Post
    hardlinks? You mean actually write htttp://blahblah/images.jpg etc? They are already hard links The problem is I don't want the other websites to know about the dataset one.
    Um..no. One search with google would have told.
    https://secure.wikimedia.org/wikiped...wiki/Hard_link
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  6. #6
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •