简体   繁体   English

htaccess 301 重定向与 URL 重写

[英]htaccess 301 redirect with URL rewrite

I would need some expert advice on how to make a proper 301 URL redirect using htaccess.我需要一些关于如何使用 htaccess 进行正确的 301 URL 重定向的专家建议。 I already have a rewrite rule and need to also add a redirect.我已经有了重写规则,还需要添加重定向。 This is the rewrite rule:这是重写规则:

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

What should I add in the rule above to make a successful redirect from:我应该在上面的规则中添加什么才能成功重定向:

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/

You need an additional rule to redirect your url, add the following bellow RewriteEngine on line :您需要一个额外的规则来重定向您的 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]

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

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