Skip to content

Instantly share code, notes, and snippets.

@guiwuff
Last active May 3, 2017 08:18
Show Gist options
  • Save guiwuff/704afb0778c5044ec7c43ea369b6aa99 to your computer and use it in GitHub Desktop.
Save guiwuff/704afb0778c5044ec7c43ea369b6aa99 to your computer and use it in GitHub Desktop.
Common regex pattern for URL Redirection in Wordpress

Common regex pattern for URL Redirection in Wordpress

  • all : (.*)
    • eg: /category/category-name/(.*).html => /category/category-name/$1/
    • redirect /category/category-name/all-kind-of-name.html into /category/category-name/all-kind-of-name/
  • 2 digit month (01-12) and 4 digit year : ((0[1-9])|(1[0-2])) and (\d{4}) eg:/category-name/article-title-(\d{4})-((0[1-9])|(1[0-2]))/ => /category-name/article-title-$2-$1/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment