I want to setup a download folder on HTTPD so that the folder it self is indexed and the files are downloaded when clicked.
I tried this, but didn't work:
# Downloads
<Directory /var/www/html/downloads>
Allow from all
Options Indexes
<Files "?*">
ForceType application/octet-stream
Header set Content-Disposition attachment
</Files>
</Directory>
Browsing to /downloads gives me the index of the folder. But clicking the files doesn't open download prompt.
Any ideas?
Regards,
--
Edit:
There seems to be something about my browser. Indeed it IS working.
Related
I want to make log files download automatically when I connect to http://myhost/download.
I know I have to deal with the .htaccess file and httpd.conf file, but the Forbidden screen keeps coming up.
Log files in download directory.
httpd.conf
Alias /download /etc/httpd/download
<Directory "/etc/httpd/download">
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
.htaccess
AddType application/force-download *.log
The server I'm working on is Amazon Linux 2.
If you know what's lacking or wrong, please share that knowledge to me.
I am setting the XAMPP on Linux Suse for my web application.
Inside htdocs folder, I created "uploads" folder for keeping Images, video files from user uploaded.
Anyway, when I try with URL http://www.my-domain-name/uploads, It is showing directoty listing
I have tried to put .httaccess file inside "uploads" folder, it is not showing directoty listing BUT I cannot access to files inside that folder.
This is my code in .httaccess file.
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
I would like to hide "directory listing" from outside BUT my app still can access all files from this folder.
I have used this code and it's working:
<IfModule authz_core_module>
Options FollowSymLinks
</IfModule>
<IfModule !authz_core_module>
Options FollowSymLinks
</IfModule>
Result: I cannot access "uploads" folder via URL BUT my app still access with all files in that folder correctly.
I've setup my server using apache2 and php5-fpm, pretty much like in this guide:
http://www.versatilewebsolutions.com/blog/2012/11/installing-apache-2-with-php-fastcgi-on-ubuntu-12-10.html
The only question left is, how can I configure it to correctly process the *.phps files?
I want to show the highlighted code of them.
There are guides for nginx and php-fpm ( https://blog.kamalnasser.net/post/highlighting-phps-files-in-nginx/ ), but what should we do with apache2 ?
Caveats: Ubuntu 14.10, Apache/2.4.10
In the file /etc/apache2/mods-available/php5.conf:
<FilesMatch ".+\.phps$">
SetHandler application/x-httpd-php-source
# Deny access to raw php sources by default
# To re-enable it's recommended to enable access to the files
# only in specific virtual host or directory
Order Deny,Allow
Deny from all
</FilesMatch>
Add a with "Allow from all" (or something more appropriate to your paranoia-level) to you host config, and you'll be all set.
My config:
<Directory /my/very/long/and/winding/server/path/public_html/phpsource/>
<FilesMatch ".+\.phps$">
Order Deny,Allow
Allow from all
</FilesMatch>
</Directory>
Php Source files in other directories get denied, the ones in that directory gets displayed. It works like a charm...
This should do it:
AddType application/x-httpd-php-source .phps
Add it to your apache config file. There should be a similar line like this:
AddType application/x-httpd-php .php
So just add it below.
I don't like how if you go to certain folders on my website that don't contain a .html file that it will list all the files in it. I don't want to give access to that. Such as: http://christianselig.com/css
How do I hide these?
You need to tell your webserver to stop directory listings. For apache, add this to your httpd.conf or any other related config file
<Directory /path/to/directory>
Options -Indexes
</Directory>
If placed in a .htaccess file, AllowOverride Options must be enabled for the desired directory.
If you are using Apache webserver and have access to httpd.conf you can set "Options -Indexes" for directory which content you want to hide.
If you have no access to httpd.conf you can create .htaccess file in directory which content you want to hide with "IndexIgnore *"
I have a Debian web-server with Apache2 installed and need to set in one directory DirectoryIndex to .html file (exactly this name - .html). But when I try to open page from browser it send 403 error.
I've changed apache2.conf (set to allow .ht files), I placed .htacess file in directory and set in it:
DirectoryIndex .html index.php index.html
AllowOverride All
Order Deny,Allow
Allow from all
But it still not work and displays 403 error. What i doing wrong and what i forget to do?
The correct answer is:
<FilesMatch "^\.html">
Order deny,allow
</FilesMatch>
DirectoryIndex .html
Sounds like you have a rule somewhere in your apache file that denys access to files starting with a .. This is generally a Good Thing, as a lot of sensitive files start with dots (ie: .htaccess, .svn, .git, .htpasswd, etc etc).
You might be able to get around the issue with something like this:
<FilesMatch "^\.html">
Order allow,deny
Allow from all
</Files>
Disclaimer: This seems like a hack. I don't know what you're trying to do, but there's probably a cleaner, less error prone way to do it.