Welcome! Log In Create A New Profile

Advanced

Re: Disable PHP in specific directories

June 10, 2010 12:36PM
You can write:
location ^~ /uploads
{
root your_root_directory;
}

This will disable trying to handle files in /uploads with different of
this location.

You can also try:
location ~* /uploads/.*\.php$
{
return 403;
error_page 403 /403_error.html;
}

And put it before your location for handling php files. This will
match all php files in uploads directory and it's subdirs and show a
error message.

On Thu, Jun 10, 2010 at 7:59 PM, mindfrost82 <nginx-forum@nginx.us> wrote:
> I have nginx setup with PHP as FastCGI.
>
> On my server, I have a couple of upload (writeable) directories and I want to disable nginx/php from serving php files in those directories (and all subdirectories).
>
> I've tried creating some location rules in nginx, but I can't seem to get it working.
>
> For example, if I have /public_html/uploads
>
> Then I have /usr1, /usr2, /usr3, etc as subdirectories under /uploads...
>
> I want to disable php in the uploads directory and all subdirectories.  Or, if its possible to redirect anyone that tries to access a *.php file in those directories to a HTML error message file...either way.
>
> Thanks!
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?2,96776,96776#msg-96776
>
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx
>



--
Boris Dolgov.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Disable PHP in specific directories

mindfrost82 June 10, 2010 11:59AM

Re: Disable PHP in specific directories

Boris Dolgov June 10, 2010 12:36PM

Re: Disable PHP in specific directories

Rob Schultz June 10, 2010 12:48PM

Re: Disable PHP in specific directories

Boris Dolgov June 10, 2010 01:32PM

Re: Disable PHP in specific directories

Rob Schultz June 10, 2010 01:42PM

Re: Disable PHP in specific directories

Igor Sysoev June 10, 2010 01:50PM

Re: Disable PHP in specific directories

Rob Schultz June 10, 2010 02:06PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 193
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready