.htaccess-仅在主页上从URL中删除参数
我在某些子页面上使用参数,但是Google出于某种原因在主页URL中索引它们。
我如何在.htaccess
仅用于主页中删除它们?
删除?a = 123
在这里:
example.com/?a=123
(结果:example.com
)
不要在此处删除它:
example.com/subpage/event.php?a=123
我找到了这个,但是我不知道如何仅将其应用于主页:
RewriteCond %{QUERY_STRING} .
RewriteRule (.*) $1?
I am using parameters on some subpages, but google index them in the search results for some reason in the homepage URL.
How can I please remove them in .htaccess
only for homepage?
remove ?a=123
here:
example.com/?a=123
(result:example.com
)
don't remove it here:
example.com/subpage/event.php?a=123
I found this, but I don't know how to apply it only for homepage:
RewriteCond %{QUERY_STRING} .
RewriteRule (.*) $1?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用以下方法:
%{query_string}。
表示“ Query String包含至少一个字符”^/?$
是“仅主页” - IE仅URL路径由可选的斜杠[r = 301]
重定向请求(更改URL)[l]
是最后一个重写规则,以便以后不会与之冲突一个[QSD]
是“ Query String delete”,因此重写不会尝试将查询字符串附加到重定向Use this:
%{QUERY_STRING} .
means "query string contains at least one character"^/?$
is "just the home page" -- ie the URL path only consists of an optional slash[R=301]
Redirects the request (to change the URL)[L]
is the last rewrite rule so that it doesn't conflict with later ones[QSD]
is "query string delete" so that rewrite doesn't try to append the query string to the redirect