的.htaccess 301重定向排除子页面 [英] .htaccess 301 redirect that excludes a subpage

查看:401
本文介绍了的.htaccess 301重定向排除子页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的规则是这样的:

RewriteRule ^page-parent.*$ http://www.domain.com/new-page/?%{QUERY_STRING} [R=301,L]

我的问题是,有一个页/页父/谢谢,我不希望被重定向。

My issue is that there is a page /page-parent/thanks that I don't want to be redirect.

我也是通过查询字符串以及使任何?添加gclid =字符串将与去。

I am also passing the query string along so that any ?gclid= string will go with.

我不能为我的生活弄清楚如何排除单个子页或所有子页面,这工作了。

I can't for the life of me figure out how to exclude a single sub page or all sub pages, which would work too.

任何帮助是AP preciated。

Any help is appreciated.

推荐答案

您可以使用mod_rewrite创造了条件:

You can use mod_rewrite to create a condition:

RewriteCond %{REQUEST_URI} !^/page-parent/thanks
RewriteRule ^page-parent.*$ http://www.domain.com/new-page/ [R=301,L]

请注意,你可以离开了?%{QUERY_STRING} 从你的目标,因为查询字符串被附加到系统默认的目标,除非你通过添加新的PARAMS一个

Note that you can leave out the ?%{QUERY_STRING} from your target, because query strings are appended to the target by default unless you've added new params via a ?.

这篇关于的.htaccess 301重定向排除子页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆