0

I have a location on nginx like this:

location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
 return 403;
 error_page 403 /403_error.html;
}

I have a php script that combines css and js files, and this rule wont return combined css or js file.

Is there a way to ignore this rule for one php file:

 /media/plg_jchoptimize/assets2/jscss.php

For all other files I want it to work.

12
  • This rules says that a 403 error is returned for any file with the suffixes listed in the last part, in any of the folders listed in the first part. Is your php file in one of the folders above? If so, you can just put it in a different folder.
    – Paul
    Apr 22, 2015 at 2:41
  • no my php file runs in background, in all site. I tried to exclude folder like this location ~* /folder/to/file(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ { } the combination change ~* didn't helped.
    – Donatas
    Apr 22, 2015 at 6:06
  • If i remove this rule the script works fine.
    – Donatas
    Apr 22, 2015 at 6:42
  • Ok, I see. Let me ask this differently. What is the URL that gets called to load the js/css file that is output from the php file? You can obscure the domain if you want.
    – Paul
    Apr 22, 2015 at 6:48
  • domain.com/path/to/js/file/30/0/… this is the output what the script gives that.
    – Donatas
    Apr 22, 2015 at 6:53

1 Answer 1

2

You can use this matching regex instead:

(images|cache|media(?!\/plg_jchoptimize)|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$

This part:

media(?!\/plg_jchoptimize)

Says match media unless it is immediately followed by /plg_jchoptimize

1
  • That what i was looking for Than You very much :)
    – Donatas
    Apr 22, 2015 at 8:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .