I am trying to use preg_match
to figure out if a url has certain pattern and right now its not working as I expected. Heres what I have so far:
if(! preg_match('^lease/([0-9]+)/?', $url)) {
wp_redirect( home_url(), 301 );
}
Basically I want to see if the url pattern is as below(lease keyword followed by a number) and if not the page should be redirected to homepage. Im not good with regex so I need some help with this one. TIA.
www.example.com/lease/324