regex - .htaccess Redirect Pattern -


i'm looking redirect pattern of letter , 2 numbers (a12,d17) (/home#d17, /home#a12).

there around 60 of these redirects hoping pattern make things easier. ideas?

redirect 301 /a1 /home#a1 redirect 301 /d13 /home#d13 

try following:
redirect 301 /([a-z][0-9]{1,2})$ /home#$1

  • ( : start of capturing group 1
  • [a-z] : match letter (lowercase)
  • [0-9]{1,2} : match 1 or 2 digits
  • ) : end of capturing group 1
  • $ : end of line

we'll use $1 reffer group 1.


Comments