WordPress网址未返回404页 [英] Wordpress URLs not returning 404 Pages

查看:131
本文介绍了WordPress网址未返回404页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

黑客入侵后,我需要有关WordPress的一些帮助。



我已彻底清除了该黑客,并且Google删除了 此网站可能被黑客攻击了标志。



该黑客向Google提交了许多URL,每个URL的末尾都包含一个随机字符串。这些在Google搜索中显示为日语链接。



列出的URL显示为:

  www.example.co.uk/? ,它显示的是网站正确的首页,而不是显示404页。



如果我转到 www.example.co.uk/thispagedoesnotesist 会显示404错误。



有没有办法让我获得包含这些随机URL字符串的页面以显示404错误?



任何帮助或建议都很好。

解决方案

您可以强制使用以下网址在 .htaccess 中包含一个长的404随机查询字符串,其内容类似于以下mod_rewrite指令。这需要在您现有的WordPress指令之前

  RewriteCond%{QUERY_STRING} ^ \w {30,} $ 
RewriteRule ^ $-[R = 404,L]

A请求包含30个或更多字母/数字的查询字符串的文档根目录(主页),然后提供404。



但是,如果这些是日语字符(而不是示例中的az),则上述字符可能不匹配,因此请尝试以下操作:

  RewriteCond%{QUERY_STRING} ^ [^ =] {30,} $ 

匹配除 = 以外的所有字符。



更新:匹配可选 = 最后,您可以在 $ <前加入 =? / code>在上述正则表达式中。例如 ^ \w {30,} =?$ ^ [^ =] {30,} =?$



如果您根本不使用查询字符串,则可以将 RewriteCond 伪指令更改为以下,与 any 查询字符串(至少1个字符)匹配。

  RewriteCond%{请求参数} 。 


I need some help with WordPress following a hack.

I've cleaned the hack completely and Google has removed the "This site may be hacked" flag.

The hack submitted a plethora of URLs to Google that contain a random string at the end of each valid URL. These show as Japanese links in google search.

There are URLs listed that show as:

www.example.co.uk/?WGlaVUdsVVNHUnNXVzFzY2xwVE1YbFphVGg1VFZSSmVFOVVTVFZQUjJNOWNFUT14b0g

If I click the link, it shows the sites correct homepage rather than showing a 404 page.

If I go to www.example.co.uk/thispagedoesnotesist it displays the 404 error just fine.

Is there a way I can get pages with these random URL strings to show a 404 error?

Any help or advice would be great.

解决方案

You can force URLs that contain a long random query string to a 404 with something like the following mod_rewrite directives in .htaccess. This needs to go before your existing WordPress directives:

RewriteCond %{QUERY_STRING} ^\w{30,}$
RewriteRule ^$ - [R=404,L]

A request for the document root (home page) that contains a query string of 30 or more letters/digits then serve a 404.

However, if these are Japanese characters in the URL (as opposed to a-z as in your example) then the above might not match, so try the following instead:

RewriteCond %{QUERY_STRING} ^[^=]{30,}$

Which matches all chars except =.

UPDATE: To match an optional = at the end then you can include =? before the $ in the above regex. For example ^\w{30,}=?$ or ^[^=]{30,}=?$.

If you don't use query strings at all then you could change the RewriteCond directive to the following, which matches any query string (that is at least 1 character).

RewriteCond %{QUERY_STRING} .

这篇关于WordPress网址未返回404页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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