This is probably easy for people who deal with these regularly, but I'm not sure what kind of code I will need to use to achieve what I want to. I know how to redirect individual URLs to other URLs, but when it comes to redirecting multiple at once I can't do it.

Basically I set up my site structure kinda bad when I built my website. I have a bunch of URLs named:

crafting-alchemist-level-1-10.php

all in the root directory, where alchemist-level-1-10 is the page name and crafting is the site section. I have about 50 of these URLs and I would like to put them all in a /crafting directory with the crafting- cut off the file names.

I could do this individually but there must be a way to do all with a single line. Is there?

These URL redirects need to be compatible with any parameters after the .php too.

I didn't think it would make any difference. But it seems to be some kind of Linux. I'm not sure where to find out as it's shared hosting. PHP Info just says Linux and doesn't list which kind.
–
XenorAug 8 '12 at 21:58

Interesting. I didn't know you could use variables like that in htaccess. I hate trying to work with regex but I figured the solution would involve a lot of that. I'll play around with that tomorrow and see if I can figure out the combination to achieve my result. Bit late to play with it tonight now.
–
XenorAug 8 '12 at 22:31

You could hard code the rules in there as well. Just depends on how much you're willing to think about it. If this is a sufficient answer, please accept it. Thank you kindly.
–
D.AAug 8 '12 at 22:34

I will accept it if I get it working. :) Would something like this work? RewriteEngine On RewriteRule ^(crafting)-(.*)$ $1/$2.php I'm not sure the best way to test it without putting it on the live server and risking messing things up. And these comments seem to hate line breaks.
–
XenorAug 9 '12 at 19:36

I have just made and tested this before seeing your latest comment: RewriteRule ^(testing)-(.*)$ mydomain.com/$1/$2 [R=301,L] This seems to work. When I tried the code I posted last time it was putting my domain's root directory in the redirect and ending it with .php.php! I will mark your answer as correct since it was sufficient enough to get me a solution. I am curious how yours works without the $2.
–
XenorAug 9 '12 at 20:01