Here I have a URL like www.abc.com/product/women/casual/page:5/ and I need to implement 301 permanent redirection using htaccess in order to change the URL to www.abc.com/product/women/casual/page/5/. In this case, parameter women and casual is customized category and subcategory and page:5 is page number 5. I need to change the last parameter page:5 to page/5 using htaccess 301 permanent redirection. Can anyone please help me to find a solution for the case.
Asked
Active
Viewed 71 times
1 Answers
0
You can use the following redirect :
RedirectMatch 301 ^/([^:]+):5/$ /$1/5/
Or a more generic one:
RedirectMatch 301 ^/([^:]+):([0-9])/?$ /$1/$2
This will redirect your old URL to the new one , for example example.com/foo/bar:digit/
to example.com/foo/bar/digit/
.
Or you can use RewriteRule
directive
RewriteEngine on
RewriteRule ^([^:]+):5/$ /$1/5/ [R=301,L]

Amit Verma
- 40,709
- 21
- 93
- 115
-
Not redirecting for me. Please suggest any other methods? – Tech Team Mar 12 '21 at 17:49
-
@TechTeam Sorry there was a typo. I updated the code and also added a RewriteRule. – Amit Verma Mar 12 '21 at 18:05
-
Thankyou, Working for me – Tech Team Mar 15 '21 at 04:17