bingjie2680
bingjie2680

Reputation: 7773

restrict access with htaccess in web server

I am using wordpress and I have a folder under wp-content/ structured as:

folder
  |-folder1
       |-file.pdf
  |-folder2
  |-.htaccess

I have all PDF files distributed within subfolders in the folder directory. I don't want all files inside the folder to be accessed directly. so I place the code in .htaccess

deny from all

but this does not seem to prevent that purpose. when I enter this url: http://mysite.come/wp-content/folder/folder1/file.pdf, the file still can be downloaded, which it shouldn't. what seems to be wrong here? thanks for help.

Upvotes: 0

Views: 809

Answers (1)

udo
udo

Reputation: 5180

the .htaccess file sets directives to the current folder and sub-folders.

important:

  • make sure that you have enabled AllowOverride All for that directory in the webserver configuration (if it is set to None change it to All and restart the web server).
  • if you want to override a directive set in an parent folder you have to place a .htaccess file in every folder you want to override (including the directives you want to override).

Upvotes: 1

Related Questions