Apache mod_rewrite regex limit matches max quantifier?
I use matchifier {} in mod_rewrite regex, rewrite the rule if the quantifier matches 1 or 2 times, and doesn't work if it matches 3 or more times. What for?
Htaccess file example:
This work (I need mydomain.com/download. An ex ):
RewriteEngine On
RewriteRule ^download\..{1,2}$ /download.php [L]
But it does not work, the error 500, modified only 2 - 3 max quantifier (I need mydomain.com/download. The exe ):
RewriteEngine On
RewriteRule ^download\..{1,3}$ /download.php [L]
It's fantastic, but it's real. Why is this so?
ps Versions:
root@andrey:/var/www/default/www# apache2 -v
Server version: Apache/2.4.7 (Ubuntu)
Server built: Jul 22 2014 14:36:38
root@andrey:/var/www/default/www# uname -a
Linux mydomain.com 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
root@andrey:/var/www/default/www# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.1 LTS
Release: 14.04
Codename: trusty
source to share
Regex \.{1,3}
works fine, but it doesn't work because it matches as well /download.php
and causes mod_rewrite to run indefinitely, resulting in a 500 error.
To overcome this, there is a negative outlook to stop rewriting when expanding .php
:
RewriteEngine On
RewriteBase /
RewriteRule ^download\.(?!php$).{1,3}$ download.php [L,NC]
source to share