php - Accessing an image folder inside public web directory

admin2025-01-07  4

I have put a folder in the public web directory of my WordPress installation where I have some images used by a legacy system.

Say its located under .png.

I have changed the rights on that folder to 0444 so it should be readable.

For some reason, I can't access the images in that folder. For some reason it returns 404.

Any clues on how to solve this?

I have put a folder in the public web directory of my WordPress installation where I have some images used by a legacy system.

Say its located under http://example.com/legacy-images/image1.png.

I have changed the rights on that folder to 0444 so it should be readable.

For some reason, I can't access the images in that folder. For some reason it returns 404.

Any clues on how to solve this?

Share Improve this question edited Feb 22, 2017 at 12:17 Fayaz 8,9872 gold badges32 silver badges51 bronze badges asked Feb 22, 2017 at 9:46 Edvard ÅkerbergEdvard Åkerberg 1111 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

For directory (folder), only read is not enough. You need to set execute also. Because for directory, execute means you can enter the directory.

Files need read permission & directory needs read & execute permission.

So the directory permission should be: 0555. However, image files inside that directory should be just read, in numeric form: 0444.

For example, in your case, /legacy-images/ directory will have 0555 permission & /legacy-images/image1.png image file will have 0444 permission.

Shell Command

If you can access shell and know how to, you may use the following shell commands (replace <WP_DIRECTORY> with appropriate WordPress installation directory):

cd <WP_DIRECTORY>
chmod 555 legacy-images/
cd legacy-images/
find ./ -type f -exec chmod 444 {} \; 
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736263948a929.html

最新回复(0)