Welcome! Log In Create A New Profile

Advanced

Restrict file without any of dots in filename

Posted by gsuser 
Restrict file without any of dots in filename
October 25, 2011 01:39PM
Hi, i'm interesting to restrict any file without dots at the name of file, e.g.: somefile, anothersomelongnamefile, ia_am_file_without_dots

I'm trying to organize location ~/ {return 403} at the end after php location and others, but it's not pleasent variant for me.
Re: Restrict file without any of dots in filename
October 25, 2011 04:33PM
If I understood you correctly, the below should work:

# match any url that does not contain "."
location ~ ^[^.]+$ {

# if the request is a filename, just issue 403 Forbidden
if (-f $request_filename) {
return 403;
}

# otherwise, it's a request to directory, so you may just want to serve index file, instead:
index index.php;
}

Andrejs
Re: Restrict file without any of dots in filename
November 03, 2011 06:20AM
Hi!

This regex is nice, but don't write that any of my links rewrites to index.php, and with your realization links like http://example.org/about http://example.org/download/clients send to me 403 because i have one index.php at docroot, end everything is going throug this index.php. Now i think over how to fix it.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 134
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