开发者

Regular expression in apache configuration file

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/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜