位置参数的htaccessredirect到基础url

如果URL包含特殊参数(URL中包含参数中的Email ),则会redirect到没有任何参数的页面的基本URL。

例如:

 http://example.com/accounts/daily/ybk/[email protected] 

 http://example.com/accounts/daily/ybk/ 

为了匹配查询string,您需要使用RewriteCond (mod_rewrite)指令并且匹配QUERY_STRING服务器variables。 例如,在您的根.htaccess文件中,请尝试以下操作:

 RewriteEngine On RewriteCond %{QUERY_STRING} Email= RewriteRule (.*) /$1? [R=301,L] 

对于包含Email=查询string中任何位置的所有URL,301将redirect到与查询string相同的URL。

这个?RewriteRulereplace的最后,从redirect的URL中删除查询string。 或者,您可以使用Apache 2.4+上的QSD标志。

如果您之前已经testing过错误的301,请确保清除浏览器caching。

更新:对于所述的具体URL(包括Email=在查询string的开头 ):

 RewriteEngine On RewriteCond %{QUERY_STRING} ^Email= RewriteRule ^(accounts/daily/ybk/)$ /$1? [R=301,L] 

mod_rewrite模块应该可以帮你。 您将条件和您的重写规则写入.htaccess文件。

参考: 使用.htaccess重写规则