Wordpress URLs not returning 404 Pages

99封情书 提交于 2019-12-06 06:30:17

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} .

The problem is that those links point to your home page with parameters. Those random strings of text are not passed as segments of url nor pages since they are preceded with ?.

There isn't a whole lot you can do. If I were in your place I would just report the links and request their removal from Google's side. Don't worry about it on your end.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!