Jump to content

[SOLVED] .htaccess & SymLinks


webent

Recommended Posts

Hi, I had someone helping me on this little project, but I haven't back from them in a few days, so I was wondering if someone could help me pick back up where it was left off...

 

Let me start by explaining what I want to accomplish,... I have a server, that has a master domain and several other domains... all of these other domains need to get their images from the master domain and they are being called via ssl...

 

So I was told that I could use .htaccess and SymLinks to accomplish this quite easily... but I've Googled by behind off and haven't found anything near what I'm trying...

 

So, here's what I was told to do...

If you can make use of .htaccess for your domains, then create a .htaccess for each one with this option:

 

Options +FollowSymLinks  (Case is important)

 

and then do this inside the documentroot for the website:

 

ln -s /where/my/master/image/directory/is dir_name_for_images/

 

 

For example:

 

cd /var/www/cartplace.com/

ln -s /usr/local/cart/common_images images/

 

Now, when you go to www.cartplace.com/images/ you'll be able to directly access the master image directory.

 

And here was my response...

Ok, wow, I think you lost me... LOL... So, I created an .htaccess, put in the line, "Options +FollowSymLinks", uploaded it to the public_html directory of the secondary domain...

 

Then logged into the server via ssh as root and typed

"ln -s /home/maindomain/public_html/supplier/images"

 

But from here I'm a bit lost... Did I do everything right so far?

 

Can someone please help me from this point? Thank you in advance for any assistance you may be able to provide.

 

Link to comment
Share on other sites

Its pretty self explanitory really. ln (thats LN) takes two arguments, the directory you wish to link to, and the name of the link.

 

So, if you has two sites /var/www/site1 & /var/www/site2 and you wanted to link the images directory from site1 into site2 you would....

 

cd /var/www/site2
ln -s /var/www/site1/images images/

Link to comment
Share on other sites

Yes, actually you make it sound very simple, thank  you... I really do appreciate it... and I did just what you said... but it's not working... I'll explain what I did...

 

cd /home/seconddomain/public_html/shoppingcart
ln -s /home/maindomain/public_html/shoppingcart/images images/

 

It took without any errors...

 

Then I went to "http://maindomain.com/shoppingcart/images/image001.jpg" and the image shows as it should, so then I go to the secondary domain, "http://seconddomain.com/shoppingcart/images/image001.jpg" and it doesn't show up...

 

Did I do something wrong again?

 

Link to comment
Share on other sites

Ok, this all worked actually, its just that I had an images directory already in the secondary domain,... So, Thorpe pointed out, by removing or renaming the images directory and then leaving off the trailing slash at the end of the line, it created an images directory for me with the SymLink in it...

 

Example:

cd /home/seconddomain/public_html/shoppingcart
ln -s /home/maindomain/public_html/shoppingcart/images images

 

Yes, actually you make it sound very simple, thank  you... I really do appreciate it... and I did just what you said... but it's not working... I'll explain what I did...

 

cd /home/seconddomain/public_html/shoppingcart
ln -s /home/maindomain/public_html/shoppingcart/images images/

 

It took without any errors...

 

Then I went to "http://maindomain.com/shoppingcart/images/image001.jpg" and the image shows as it should, so then I go to the secondary domain, "http://seconddomain.com/shoppingcart/images/image001.jpg" and it doesn't show up...

 

Did I do something wrong again?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.