質問

I need to turn off php_flag for some directories on my server.

The directory name is 'images/' and is located in these directories:

/var/www/html/mysite1/images/

/var/www/html/anysitename/images/

/var/www/html/something/images/

....

What regular expression do i need to insert in apache config file?

Thank you.

役に立ちましたか?

解決

Try this:

/var/www/html/(mysite1|something|[^/]+)/images/

Meaning: Either "mysite" or "something" or "a character sequence containing anything but a forward slash".

他のヒント

Apache use Perl-compatible regular expression as mention here.

You can check your regular expressions with this online tool: https://regex101.com/r/gO4eS8/5

As mention in Apache's documentation, Apache understand v5 Perl Compatible Regular Expressions (PCRE) from version 2.2.

For this case the following regular expression should do the job (matching directories and content): /var/www/html/(|[^/]+)/images/?(?:[^\/]+)?$

Test string:

/folder1/images/test1
/var/www/html/images
/folder2/images/test1
/folder2/mysite1/test2
/var/www/html/mysite2/images/foo.png
/var/www/html/anysitename/images/
/var/www/html/something/images/

Strings matching:

/var/www/html/mysite2/images/foo.png
/var/www/html/anysitename/images/
/var/www/html/something/images/
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top