.htaccess - How would you apply rewrite rules to redirect old link structure to new? -


i had links on site structure:

  1. site.com/category/1/cat1name (can have dashes)
  2. site.com/lessons/1/lesson1name (can have dashes)
  3. site.com/exercise/1/exname (can have dashes)

i changed structure to

  1. site.com/guitar-lessons/cat1name/1
  2. site.com/guitar-lesson/lesson1name/1
  3. 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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -