使.htaccess重定向以开头的垃圾邮件链接?到错误页面 [英] Make .htaccess redirect spamy links that start with ? to an error page

查看:66
本文介绍了使.htaccess重定向以开头的垃圾邮件链接?到错误页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了很多代码,现在我在这里.有没有一种方法可以通过我的.htaccess文件(这是一个wordpress网站)将垃圾邮件链接重定向回404错误或410错误消失的页面,所有链接均以?开头?标记-例如,它们是:www.mydomain.com/?spam-link-here链接,现在它们都转到主页,我希望它们转到404或410错误页面.因此,它必须要以以?开头的查询字符串为目标.标记目标代码.

I have tried lots of code and now I'm here. Is there a way I can redirect spamy links back to a 404 error or 410 error gone page, through my .htaccess file (it's a wordpress site) the links all start with a ? mark - so for example they are: www.mydomain.com/?spam-link-here link, right now they are all going to the home page and I would like them to go to either a 404 or 410 error page. So it needs to be something that targets a query string that starts with a ? mark targeted code.

**仅供参考,我已经加强了我的htaccess文件,只需要这部分的帮助,谢谢

**FYI I have hardened my htaccess file, just need help with this part, thanks

在我放入的.htaccess根目录中:

in the root directory .htaccess I put:

RewriteEngine On
RewriteBase /

# Get the strings but no empty strings because of home failure
RewriteCond %{QUERY_STRING} .

# AND try to exclude normal searches, CSS and Javascript:
RewriteCond %{QUERY_STRING} !^s=(.*)$
RewriteCond %{QUERY_STRING} !^c=(.*)$
RewriteCond %{QUERY_STRING} !^ver=(.*)$
RewriteCond %{REQUEST_URI} !^/wp-login\.php

# AND try not to rewrite specific directories:
RewriteCond %{REQUEST_URI} !^wp-admin/
RewriteCond %{REQUEST_URI} !^wp-content/

# Do it
RewriteRule ^(.*)$ http://www.yoursite.com.au/$1? [G,NC]

然后在wp-admin中输入:

And in the wp-admin I put:

RewriteEngine On
RewriteBase /

RewriteCond $1 !^(edit\.php|edit-tags\.php|upload\.php|link-manager\.php|post-new\.php|post\.php|admin\.php|themes\.php|widgets\.php|theme-editor\.php|plugin-install\.php|plugin-editor\.php|profile\.php|tools\.php|customize\.php|nav-menus\.php|users\.php|options-general\.php|options-writing\.php|options-media\.php|options-reading\.php|options-discussion\.php|options-media\php|options-permalink\.php|)
RewriteRule ^(.*)$ http://www.yoursite.com.au/$1? [G,NC]

完成仪表盘;如果它使垃圾邮件链接重定向到错误页面,我什至不在乎.我在那里尝试了很多其他代码.这段代码对另一个人有用,但对我却不起作用...不知道为什么.

Messed up the dashboard; which I wouldn't even care about it if it made the spamy links re-direct to an error page. I tried tons of other code in there; this code worked for another guy but it's not working for me...not sure why.

这是另一个线程的链接,我很希望它最终在stackoverflow上得到解决. 获得最新代码集的线程

Here's the link from the other thread, I was so hoping it finally get solved here on stackoverflow. thread where I got the latest set of code

推荐答案

我得到了其他一些额外的帮助,这似乎终于奏效了,在任何包含不带=符号的查询字符串的URL上返回404响应.

I got some other extra help and this is what finally seems to be working, return a 404 response on any URL that includes a query string with no = symbol.

###BAD QUERY STRING BLOCKER, ADDED 5/26/2016
<IfModule mod_rewrite.c>
RewriteCond %{QUERY_STRING} ^[\-/A-Z0-9]+$ [NC]
RewriteRule (.*) - [R=404]
</IfModule>
###END CODE

似乎至少要将垃圾邮件链接重定向到错误页面!

Seems to be at least re-directing the spamy links to an error page!

这篇关于使.htaccess重定向以开头的垃圾邮件链接?到错误页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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