Question

I am trying to let useres upload their pictures at my website and I don't want to let others to see them, even if they know their URL. I would like to implement something like unaccesible folder at apache. (If it is possible from .htacess) I don't want to put them into database, because it slows server quite a lot (imo). Is there a solution? I saw something at FB, but its quite different league.

Was it helpful?

Solution

You can disable public access to a directory using the .htaccess

RewriteEngine On
RewriteRule ^(?:images)\b.* index.php/$0 [L]

This would forward requests to the images folder to your index.php file.

This will only work if you have mod_rewrite enabled.

Also you could add a .htaccess file to the folder you would like to disable public access to and add the following rule.

deny from all
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top