简体   繁体   English

301 htaccess使用目录通配符重定向

[英]301 htaccess redirect with directory wildcard

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/ 看来我需要通配符/1990/的子目录

Being able to do this would greatly decrease the number of redirects I have, making it more manageable. 能够做到这一点将大大减少我的重定向次数,使其更易于管理。 Any help or hints appreciated! 任何帮助或提示表示赞赏!

您可以对所有这些规则使用一个规则:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM