【发布时间】:2021-05-05 06:36:03
【问题描述】:
由于不值得在这里讨论的原因,Google 一直在索引我的一个网站,网址中包含不必要的查询字符串 wordfence_lh、hid 和 wordfence_logHuman。我想修改我的 .htaccess 文件以删除所有这些查询字符串。
我的网址
example.com/page/111/?wordfence_lh=1&hid=CA2BA660BEFF26B9A17F8F85D7391BD4
example.com/page/80/?wordfence_logHuman=1&hid=647700EBF43600E7BC54103256F1D71B
预期网址
example.com/page/111/
example.com/page/80/
我找到了一种删除单个参数的方法,但我仍然找不到正则表达式或其他东西来删除多个查询参数。 非常感谢任何帮助,非常感谢!
这是我的.htaccess 文件的一部分:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} on [OR]
RewriteCond %{SERVER_PORT} ^555$ [OR]
RewriteCond %{HTTP:X-Forwarded-Proto} https
RewriteRule .* - [E=WPR_SSL:-https]
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=WPR_ENC:_gzip]
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{QUERY_STRING} =""
RewriteCond %{HTTP:Cookie} !(wordpress_logged_in_.+|wp-postpass_|wptouch_switch_toggle|comment_author_|comment_author_email_) [NC]
RewriteCond %{REQUEST_URI} !^(/(.+/)?feed/?.+/?|/(?:.+/)?embed/|/(index\.php/)?wp\-json(/.*|$)|/cantonicalt/)$ [NC]
RewriteCond %{HTTP_USER_AGENT} !^(facebookexternalhit).* [NC]
RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/%{HTTP_HOST}%{REQUEST_URI}/index%{ENV:WPR_SSL}%{ENV:WPR_WEBP}.html%{ENV:WPR_ENC}" -f
RewriteRule .* "/wp-content/cache/wp-rocket/%{HTTP_HOST}%{REQUEST_URI}/index%{ENV:WPR_SSL}%{ENV:WPR_WEBP}.html%{ENV:WPR_ENC}" [L]
</IfModule>
【问题讨论】:
-
欢迎来到 SO,请在您的问题中分享您的 htaccess 文件,谢谢。
-
@RavinderSingh13 我刚刚更新了我当前的 htaccess 代码。
-
更多信息:wordfence 插件是造成这种情况的原因。我卸载了它,但这些 URL 参数并没有消失!
-
好的,所以您在浏览器中点击了网址
example.com.com/page/111/,并且您希望它由example.com/page/111/?wordfence_lh=1&hid=CA2BA660BEFF26B9A17F8F85D7391BD4提供服务? -
@RavinderSingh13 不,我只想删除我所有 URL 中的
?wordfence_lh=1&hid=CA2BA660BEFF26B9A17F8F85D7391BD4部分。谷歌机器人抓取并索引它们使我重复的内容。换句话说,我想摆脱这些参数,它们是 wordfence_lh、hid 和 wordfence_logHuman。 URL 应该是example.com.com/page/111/
标签: wordpress .htaccess query-string url-parameters