301 htaccess redirect with directory wildcard

2.4k Views Asked by At

Is there a more efficient way to write these redirects?

RewriteRule ^directory/subdir/1990/010190/(.*)$ directory/editorials/$1 [L,R=301]
RewriteRule ^directory/subdir/1990/020190/(.*)$ directory/editorials/$1 [L,R=301]
RewriteRule ^directory/subdir/1990/030190/(.*)$ directory/editorials/$1 [L,R=301]
RewriteRule ^directory/subdir/1990/040190/(.*)$ directory/editorials/$1 [L,R=301]
RewriteRule ^directory/subdir/1990/050190/(.*)$ directory/editorials/$1 [L,R=301]
RewriteRule ^directory/subdir/1990/060190/(.*)$ directory/editorials/$1 [L,R=301]

It seems like I need a wildcard for the subdirectory of /1990/

Being able to do this would greatly decrease the number of redirects I have, making it more manageable. Any help or hints appreciated!

1

There are 1 best solutions below

2
On BEST ANSWER

You can use a single rule for all of those rules:

RewriteRule ^directory/subdir/1990/0[1-6]0190/(.*)$ directory/editorials/$1 [L,R=301]