htaccess 301 重定向 URL 重写

htaccess 301 redirect with URL rewrite

我需要一些专家建议,了解如何使用 htaccess 进行正确的 301 URL 重定向。我已经有一个重写规则,还需要添加一个重定向。这是重写规则:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^results/(case1|case2|case3)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ /results.php?v1=&v2=&v3=&v4=&v5=&v6=&v7= [L]

我应该在上面的规则中添加什么才能成功重定向自:

http://www.website.com/results.php?v1=case2&v2=a&v3=b&v4=c&v5=d&v6=e&v7=f
to:
http://www.website.com/results/case2/a/b/c/d/e/f/

您需要一条附加规则来重定向您的 url,在 RewriteEngine on 行下方添加以下内容:

 RewriteCond %{THE_REQUEST} /results\.php\?v1=(case1|case2|case3)&v2=([^&]+)&v3=([^&]+)&v4=([^&]+)&v5=([^&]+)&v6=([^&]+)&v7=([^&\s]+)\sHTTP [NC]
RewriteRule ^ /results/%1/%2/%3/%4/%5/%6/%7? [NC,L,R=301]