Maybe I'm doing something stupid, but I can't get rid of an issue with htaccess.
I'm trying to match a function name in a documentation site and I'm getting errors I can't understand. I must point that I (think I) know about regular expressions escaping, and I know what dot and backslash-dot mean.
So: i want to allow all of these:
example.com/foofunction
example.com/foofunction.php
example.com/function.foofunction
example.com/function.foofunction.php
These are the lines that I've tried. Those which cause error are misunderstood, so lots of thanks to anyone that can explain any to me:
^function\.([A-Za-z0-9_-]+)(\.php)?$
-> works, but makes function.
mandatory
^(function\.)?([A-Za-z0-9_-]+)(\.php)?$
-> internal error... ok, let's not escape dot, in the end, it will match any character and will work...
^(function.)?([A-Za-z0-9_-]+)(\.php)?$
-> internal error too! ok, just for trying, dot outside conditional?
^(function)?\.([A-Za-z0-9_-]+)(\.php)?$
-> works, ok, but it makes dot mandatory. By the way, more crazy things:
^(function)?.([A-Za-z0-9_-]+)(\.php)?$
-> if dot isn't escaped (imagine I want to allow any character), internal error too. Now i`ll try to make dot optional separately
^(function)?(\.)?([A-Za-z0-9_-]+)(\.php)?$
-> internal error too, i'm going crazy...
These are my tries up to now, I'm going to try optional lookbehind and update with results... anyway, i'd love to understand whi those regexes cause internal error.
And if anyone knows about an "htaccess special regex exceptions" reference or something like that i must read, wil be very wellcome.
Thanks in advance to all of you guys.