0

I recently started serving images to my wordpress website via a subdomain. It worked perfectly.

But i noticed that if i enter the subdomain url eg. http://media.domain.com into the browser it displays all my files in the uploads folder.

I would love to make this inaccessible to the public. Only the direct links to the media files should be available for download and the subdomain folder shouldnt be made accessible via the browser.

Please how do i go about doing that?

I have tried to change the permission on the subdomain folder from cpanel but seems like i dont have the right permission.

2

To prevent folder listing you could add an .htaccess file to the root of your subdomain with this content:

Options -Indexes
  • what effect would adding the content to the .htaccess file in the public_html folder. @remy – proton Jun 9 '16 at 20:39
  • 1
    this will prevent the folder listing. so when you hit a folder or root and not a file, you wont see anymore the list of all files. – rémy Jun 9 '16 at 20:46
  • Alternatively you can also create a blank index.html / index.php file, which will cause that file to be served instead of the directory listing. – Tim Malone Jun 10 '16 at 0:19
  • @TimMalone its a wordpress website. Adding a blank .php file to it would mean always having to add a new php script whenever we start a new month. Because the uploads folder is organized into folders in years and months. For example media.domain.com/2016/05 is for uploads made in may 2016 and media.domain.com/2016/06 is for uploads made in june 2016. – proton Jun 10 '16 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.