I have the following redirect in my htaccess:
Redirect 301 "^/city/(.*)-north-carolina$" "https://example.com/US/NC/$1-north-carolina-hotels.php"
When I enter example.com/city/asheville-north-carolina I don't get the redirect like I should. Something wrong with my syntax or does something need to happen with RewriteCond?
I've tried various version of the syntax, nothing
The
Redirectdirective only takes a static URL as input.To solve it, either :
Replace
RedirectbyRedirectMatch:Here,
RedirectMatchwill receive the leading slash of the URL.Or
Use a
RewriteRule:In this case,
RewriteRulereceives the path without the leading slash.