本文介绍了在.htaccess和preserve查询字符串替换URL的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我发了封邮件出去的许多的人以错误的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 正确的URL: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 唯一的区别是目录从的改变而使格尔伍德到的恩膏。我需要保留查询字符串,这应该是一个302。建议? 修改 如果原来不正确的URL包含以下查询参数和值这302重定向,才会发生: utm_campaign =章+ 15 +的+涂油 解决方案 到的httpd.conf 启用了mod_rewrite和.htaccess,然后把这个code在的.htaccess $ DOCUMENT_ROOT 目录下: 选项+了FollowSymLinks -MultiViews#开启mod_rewrite的上RewriteEngine叙述上的RewriteBase /的RewriteCond%{QUERY_STRING}(^ |&安培;)utm_campaign =章\ +15 \ +的\ +涂油(安培; | $)[NC]重写规则^(章)/离开格尔伍德/?/ $ 1 /的恩膏/ [L,NC,R = 302] I sent an email out to lots of people with the wrong URL and need to fix it with .htaccess. The wrong URL: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%20JesusThe correct URL: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%20JesusThe only difference is the change of the directory from leaving-tanglewood to the-anointed. I need to retain the query string, and this should be a 302.Suggestions?EDITThis 302 redirect should only occur if the original incorrect URL contains the following query parameter and value:utm_campaign=Chapter+15+The+Anointed 解决方案 Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:Options +FollowSymLinks -MultiViews# Turn mod_rewrite onRewriteEngine OnRewriteBase /RewriteCond %{QUERY_STRING} (^|&)utm_campaign=Chapter\+15\+The\+Anointed(&|$) [NC]RewriteRule ^(chapters)/leaving-tanglewood/?$ /$1/the-anointed/ [L,NC,R=302] 这篇关于在.htaccess和preserve查询字符串替换URL的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-24 02:58