I am using the following code in my htaccess file
Redirect 301 /([0-9]{1,2})+_([A-Za-z])$ /brand/$1-$2
to redirect the following type of URL pattern :
www.mywebsite.com/{ID}_{BrandName}
So basically I have to redirect
www.mywebsite.com/{ID}_{BrandName} to www.mywebsite.com/brand/{ID}-{BrandName}.
For example : Redirect 301 to www.mywebsite.com/5_TestBrand to www.mywebsite.com/brand/5-TestBrand.
Please suggest.
Below is the htaccess code which is not working :
Redirect 301 /([0-9]{1,2})+_([A-Za-z])$ /brand/$1-$2
Please Guide.
Thanks !
You cannot use regex and captured groups in Redirect directive. Use RediectMatch instead:
RedirectMatch 301 ^/([0-9]+)_([A-Za-z]+)/?$ /brand/$1-$2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With