By Jehan Fillat
Hello,
I’ve setup a small droplet with php7.0-fpm/fastcgi, apache 2.4 on a Ubuntu 14.04. Everything runs smoothly, except one small detail :
The thing is I want to protect a folder via a classic .htaccess protection, nothing fancy.
But, if I go to “my-droplet-ip/my-protected-folder/my-file.php”, I still can access it, even with an htaccess configured.
If I go to “my-droplet-ip/my-protected-folder”, the login/pass prompt shows up like expected. Same normal behavior for “my-droplet-ip/my-protected-folder/a-file.(html/png/ini…)”
I’ve read many things, like the fact that fastcgi could “process” php files before htaccess, but I can’t really figure why/how.
Any idea?
Thanks!
Jehan
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Eureka.
Short story, don’t use :
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1
to handle php files with FastCGI, because it seems that ProxyPassMatch directives are evaluated before the .htaccess.
Better use :
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
More details over there.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.