Reputation: 9664
I am trying to write a rule to skip over a fake directory with .htaccess. I have achieved this like
RewriteRule ^fake/(.+)$ /$1 [N,NC]
so now /fake/real would just get /real
But I have a need to target anything which is in the format xx-xx like en-gb or en-us
I have tried something like
RewriteRule ^a{5}/(.+)$ /$1 [N,NC]
which should try and match anything of length 5. But this does not work, and is only half the job anyway. How can I match anything like xx-xx ?
Upvotes: 2
Views: 73
Reputation: 80639
When you do a{5}
, it means match the character a
five times.
You want to match 2 alphabets, followed by a -
and again 2 alphabets:
[a-z]{2}\-[a-z]{2}
The [NC]
flag will take care of EN-gb
or eN-gB
etc. too.
Upvotes: 1