[英]Regular expression in apache configuration file
I need to turn off php_flag for some directories on my server. 我需要为服务器上的某些目录关闭php_flag。
The directory name is 'images/' and is located in these directories: 目录名称为“ images /”,位于以下目录中:
/var/www/html/mysite1/images/ / var / www / html / mysite1 / images /
/var/www/html/anysitename/images/ / var / www / html / anysitename / images /
/var/www/html/something/images/ / var / www / html / something / images /
.... ....
What regular expression do i need to insert in apache config file? 我需要在apache配置文件中插入什么正则表达式?
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". 含义:“ mysite”,“ something”或“除了正斜杠之外的任何字符序列”。
Apache use Perl-compatible regular expression as mention here . Apache使用与Perl兼容的正则表达式,如此处所述 。
You can check your regular expressions with this online tool: https://regex101.com/r/gO4eS8/5 您可以使用此在线工具检查正则表达式: https : //regex101.com/r/gO4eS8/5
As mention in Apache's documentation , Apache understand v5 Perl Compatible Regular Expressions (PCRE) from version 2.2. 如Apache文档中所述 ,Apache从2.2版开始理解v5 Perl兼容正则表达式(PCRE)。
For this case the following regular expression should do the job (matching directories and content): /var/www/html/(|[^/]+)/images/?(?:[^\\/]+)?$
对于这种情况,以下正则表达式应该起作用(匹配目录和内容):
/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 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.