Last active
July 26, 2021 18:12
-
-
Save slava-konashkov/9f213d196f3c68ccbd6c5d879f4d4734 to your computer and use it in GitHub Desktop.
PHP regex Apache access log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$regex = '/^(?P<IP>\S+) | |
\ (?P<ident>\S) | |
\ (?P<auth_user>.*?) # Spaces are allowed here, can be empty. | |
\ (?P<date>\[[^]]+\]) | |
\ "(?P<http_start_line>.+ .+)" # At least one space: HTTP 0.9 | |
\ (?P<status_code>[0-9]+) # Status code is _always_ an integer | |
\ (?P<response_size>(?:[0-9]+|-)) # Response size can be - | |
\ "(?P<referrer>.*)" # Referrer can contains everything: its just a header | |
\ "(?P<user_agent>.*)"$/xU'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment