7

From another answer, this double slash dot is common

RedirectMatch 404 /\\.svn(/|$)

Since we're matching "/.svn" etc., why isn't this a single slash to escape the period?

Community
  • 1
  • 1
Eric
  • 83
  • 5
  • According to [this help page](http://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirectmatch) the backslash must be single to match a literal dot. – Wiktor Stribiżew Oct 12 '15 at 18:08
  • 2
    If there is anyone who could explain the [source code](http://opensource.apple.com/source/apache/apache-647/apache/src/modules/standard/mod_alias.c), I will upvote. – Wiktor Stribiżew Oct 12 '15 at 18:23

1 Answers1

1

Double escaping is allowed here but not really required. So both of these rules will work:

RedirectMatch 410 /\\.svn(/|$)

OR

RedirectMatch 410 /\.svn(/|$)
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Why does that work though? If you wanted to literally match a file called `\.svn` the double backslash doesn't work, but you need to use the regex `/\\\.svn` (3 of them), whereas the PCRE backslash works differently in mod_rewrite (only need 1, but 2 will match the file \.svn). – Jon Lin Oct 12 '15 at 17:25
  • Good point Jon. I just went by this line in question `Since we're matching "/.svn" etc`. I am not sure if `RedirectMatch` (or `mod_alias`) regex engine is same as as the one used by `mod_rewrite` (PCRE). – anubhava Oct 12 '15 at 17:28
  • @JonLin I can understand the `/\\\.svn` matching `\.svn` literally. I do have problem understanding why `\\.svn` works though – hjpotter92 Oct 12 '15 at 18:47
  • In this example, we're excluding access to ".svn" folders, so my assumption is the pattern is "/.svn", not "/\.svn". If I understand correctly, the conclusion so far is that both "\\." and "\." stand for a single period, but nobody knows why? – Eric Oct 13 '15 at 17:05
  • @Eric: Yes that is correct both `\\.` and `\.` behave same for `RedirectMatch` directive. – anubhava Oct 13 '15 at 17:16