.htaccess - How would you apply rewrite rules to redirect old link structure to new? -
i had links on site structure:
- site.com/category/1/cat1name (can have dashes)
- site.com/lessons/1/lesson1name (can have dashes)
- site.com/exercise/1/exname (can have dashes)
i changed structure to
- site.com/guitar-lessons/cat1name/1
- site.com/guitar-lesson/lesson1name/1
- site.com/guitar-lesson-ex/exname/1
i using laravel , know can use routes take care of this, want use 301 redirects old link structure new.
i not sure how 1 creates proper rewriterule factor in different url parts , reordering.
examples have read seem have nuances specific needs. being new rewriterules, not sure how construct rule. case 1 above tried
rewriterule ^category/(.*)$/(.*)$ guitar-lessons/$2/$1 [nc,r=301]
but using htaccess tester doesn't produce match.
any suggestions?
thanks!
ok, shouldn't have posted quickly. realized didn't need $ symbol in first part of rule. had seen this example , thought needed use '$'. rule working:
rewriterule ^category/(.*)/(.*) guitar-lessons/$2/$1 [nc,r=301]
Comments
Post a Comment