[英]Filtering pages to redirect to 404 in .htaccess
I have a site that use to have a search engine script on it, that has been removed and replaced with new content. 我有一个网站,上面曾经有一个搜索引擎脚本,该网站已被删除并替换为新内容。
Every so often the site gets flooded with requests like: 网站每隔一段时间就会收到大量要求,例如:
/index.php?page=search/web/appdojo.com
/index.php?page=search/web/2tu.us
/index.php?page=search/emailafriend&url=http%253A%252F%252F
/index.php?page=user/viewcomments/images/82e10127b84ee2750c
This then causes a huge amount of processes to start up and then we have problems with the hosting provider. 然后,这将导致启动大量进程,然后我们与托管服务提供商发生了问题。
I'm thinking I should be able to stop these in .htaccess
before index.php
is called but haven't figured out a regex
expression to do that but to let the rest of the index.php
url's to pass through OK. 我想我应该能够在调用
index.php
之前在.htaccess
停止这些操作,但是还没有想出regex
表达式来执行此操作,而是让其余的index.php
URL通过OK。
Can anyone help out? 有人可以帮忙吗? -thanks
-谢谢
Since you include PHP in your tags, it would be far easier to simply show a 404 error on the index.php and make it seem to be an error. 由于您在标记中包含PHP,因此在index.php上简单显示404错误并使它看起来像是一个错误会容易得多。 So you can put this before everything on the index.php page:
因此,您可以将它放在index.php页面上的所有内容之前:
if (isset($_GET['page'])) {
header('HTTP/1.0 404 Not Found');
include('404.php'); //Whatever your 404 error page is
exit();
}
如果您的索引页面根本没有使用page变量,则可以尝试阻止所有在URL中具有页面参数的URL
RewriteRule ^index.php?page= /Your_404_page.php
Yes it is better to stop them at .htaccess stage to prevent loading PHP. 是的,最好在.htaccess阶段将其停止,以防止加载PHP。 Here is the rule that will work for you in
DOCUMENT_ROOT/.htaccess
file: 这是适用于
DOCUMENT_ROOT/.htaccess
文件的规则:
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php\?page= [NC]
RewriteRule ^ - [R=304,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.