Regular Expressions 101

Community Patterns

Pretty URLs: match ugly URL tails

0

Regular Expression
PCRE2 (PHP >=7.3)

/
((\/(index(\..+)?)?)|(\..{2,4}))$
/
gm

Description

Matches: ...foo/bar.php ...foo/bar/ ...foo/bar/index ...foo/bar/index.php

Returns: ...foo/bar

Submitted by DM - 2 years ago (Last modified 2 years ago)