1

我用错误的 URL 向很多人发送了一封电子邮件,需要使用 .htaccess 修复它。错误的网址:

https://amemoirproject.com/chapters/leaving-tanglewood/?utm_medium=email&utm_campaign=Chapter+15+The+Anointed&utm_content=Chapter+15+The+Anointed+CID_6d1662ca75fabbdcbd66397fc00cdcf4&utm_source=Campaign%20Monitor&utm_term=Chapter%2015%20The%20Anointed%20%20A%20Long-Haired%20Handsome%20Jesus

正确的网址:

https://amemoirproject.com/chapters/the-anointed/?utm_medium=email&utm_campaign=Chapter+15+The+Anointed&utm_content=Chapter+15+The+Anointed+CID_6d1662ca75fabbdcbd66397fc00cdcf4&utm_source=Campaign%20Monitor&utm_term=Chapter%2015%20The%20Anointed%20%20A%20Long-Haired%20Handsome%20Jesus

唯一的区别是目录从 更改leaving-tanglewoodthe-anointed。我需要保留查询字符串,这应该是 302。

建议?

编辑

仅当原始错误 URL 包含以下查询参数和值时,才会发生此 302 重定向:

utm_campaign=Chapter+15+The+Anointed
4

1 回答 1

1

通过启用 mod_rewrite 和 .htaccess httpd.conf,然后将此代码放在您.htaccessDOCUMENT_ROOT目录下:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} (^|&)utm_campaign=Chapter\+15\+The\+Anointed(&|$) [NC]
RewriteRule ^(chapters)/leaving-tanglewood/?$ /$1/the-anointed/ [L,NC,R=302]
于 2013-08-19T14:30:27.990 回答