1

I have all the photos of my website located in /var/www/vhosts/myvps.ovh.net/sitename/uploads/, and my site is located in /var/www/vhosts/myvps.ovh.net/httpdocs, sitename and httpdocs are located on the same level. When a user looks for some photos I want to look into /sitename/uploads and not /httpdocs/uploads, my htaccess file is located in httpdocs/.htaccess. I tryied using RewriteRule like this:

RewriteRule ^/var/www/vhosts/myvps.ovh.net/sitename/uploads/(.*)/$ uploads/$1 [QSA]

but nothing changed, I've been trying different RewriteRules for a while now and I can't figure out one that should work.
Any Ideas? thanks

3
  • Apache cannot load content from outside DocumentRoot and here /sitename/ is outside DocumentRoot Commented Dec 7, 2015 at 15:24
  • 1
    mod_write works on urls, not filesystem paths. Commented Dec 7, 2015 at 15:24
  • The correct way to do this is to redirect your image requests to a script then have the script serve the files. See my answer here for an example: stackoverflow.com/questions/34136239/… Commented Dec 7, 2015 at 15:29

2 Answers 2

2

I would use this directive in my /etc/apache2/sites-enabled/myweb.conf:

Alias /upload/ /var/www/vhosts/myvps.ovh.net/sitename/uploads/
<Location /upload>
Require all granted
    SetHandler None
</Location>

Then any web request for http://myweb/upload/file.ext would send the file /var/www/vhosts/myvps.ovh.net/sitename/uploads/file.ext to the browser.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi, thanks for your help, unfortunately I'm using plesk(not my decision) and I can't find a way to access teh file you mention, I have only access to /var/www/vhosts/myvps.ovh.net/ subfolders, any suggestions on how to solve this?
Sorry, I have root on all my computers, so I can edit anything in /etc and therefore did not solve such problems. If it would not work from .htaccess, I am afraid I cannot help you with this :(
1

I solved my problem adding a RewriteRule to my htaccess like this RewriteRule ^/uploads(.*) /var/www/vhosts/myvps.ovh.net/sitename/uploads/.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.