G
G
Galdar Turin2019-11-15 09:10:21
Nginx
Galdar Turin, 2019-11-15 09:10:21

How to use a regular expression to select a folder with any name?

I want to specify any directory name in the exception, but for some reason it does not work (.+), swears that there is no fixed length
+ A quantifier inside a lookbehind makes it non-fixed width

^/c/.+\.(min\.js|js|php|cgi|pl|phtml)(?<!index\.php|d\.php|t\.js|app/project/_resource/s/|app/project/ вот_тут_любое_имя_каталога  /js/с\.min\.js)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-11-19
@Galdar

In the /c/ directory, deny access to all files except:
/c/index.php
/c/d.php
/c/t.js
/c/app/project/_resource/s/
/c/app/project/[^ /]+/js/c\.min\.js

location ~ ^/c/(?!index\.php|d\.php|t\.js|app/project/_resource/s/|app/project/[^/]+/js/c\.min\.js) {
    return 403;
}

Or
location ^~ /c/ {
    return 403;

    location ~ ^/c/(index|d)\.php {
        fastcgi_pass ...;
        include fastcgi_params;
    }

    location = /c/t.js { }

    location /c/app/project/_resource/s/ { }

    location ~ ^/c/app/project/[^/]+/js/c\.min\.js { }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question