简体   繁体   中英

Accessing Images from /etc/images directory instead of /var/www directory

The whole PHP application is under this /var/www directory. But images folder is in /etc/images. How to access these images in /etc/images directory using PHP.

在/ etc / images和/ var / www / images之间添加具有适当权限的符号链接

I would try to keep for using symlinks to outside your www folder, but if your images but be served from that folder then symlink is probably your best bet.

You could also use php to create a tmp image based on your image in the folder outside of your www. This way your server scripting language (php) would have access to this non-www folder and create an image in a tmp folder within your www folder on demand, segregating your system folders from the web.

That depends on what webserver you're using:

Are you using the php-internal development webserver? Just symlink from /var/www/images to /etc/images.

Are you using Apache? Then the solution is two-folds:

  1. Enable serving content from /etc/images
  2. Point the URL to the directory

     <Directory /etc/images> order allow,deny allow from all </Directory> Alias /images /etc/images/ 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM