Regex to detect a proper permalink?
- by Fedor
These permalinks above are rerouted to my page:
page.php?permalink=events/foo
page.php?permalink=events/foo/
page.php?permalink=ru/events/foo
page.php?permalink=ru/events/foo/
The events is dynamic, it could be specials or packages.
My dilemma is basically; I need to detect an empty link in order so I can feed a robots no index meta tag in the case of:
page.php?permalink=events
page.php?permalink=events/
page.php?permalink=ru/events/
page.php?permalink=ru/events
I can't use a simple pattern such as [a-zA-Z]+\/?(.+)/ since it won't work on the i18n permalinks.
What regex could I use which would detect this, using $_GET['permalink'] as the reference to the permalinks? And avoid false positives?
Update:
Empty link means there's no fragment after the "events/" part. These are empty:
page.php?permalink=events
page.php?permalink=events/
page.php?permalink=ru/events/
page.php?permalink=ru/events