Hi guys,

I need your help. I have .xml file in download directory on my server. whoever visit my site page (Myxmlfilename.xml) user should be able to download these files and other files should not.

I am trying to achieve above but no luck...

does anyone know how I can access to Myxmlfilename.xml to download the xml file?

thank you in advance.

Since in .htaccess the rules have a cascading order, for a simple "manual" solution you could save this .htaccess file into the download directory:

<Files "*">
order allow,deny
deny from all

<Files "Myxmlfilename.xml">
order allow,deny
allow from all

This would deny the direct access to all the files, except to Myxmlfilename.xml. For a complex solution you could:

  1. separate the files in a public download directory and a reserved, or
  2. deny direct access to the download directory and use a script to serve the files, for example: