Home Backend Development PHP Tutorial 用PHP?改?你的404???,?其威力不可?

用PHP?改?你的404???,?其威力不可?

Jun 23, 2016 pm 02:37 PM

    404??,很多人都知道,如果要??的url不存在的?候就?取?示???面.以往在?理404方面我?通常的做法是要?????行字,而有心人士或????其稍加美化,另外一少部份想投?取巧的?伙甚至用meta??做延??向,?此而已,其?404?可以?我?做很多事,?就是今天我?要??的重?了.

    首先我??明一下我的404究竟都能?我做哪些事情:

1.他可以告?我何??自哪?的用?要??我哪?URL?果失?了.

2.他能告?我?方?何要????URL,并?助我?化?站

3.他能告?我?方的IP地址

4.他能告?我此人的居心何在

5.我可以?他把那些不想告?我的??嘴

6.他能把他想要告?我的用email方式??我

7.他能?我做301永久重定向.

8.他能告?我有人正在??入侵我的?站或主?

    ?起?很玄也很炫,好吧,接下?我?就???一下究竟他是怎?做到的.逐一分析:

1.我?可以用PHP捕捉用?的?源URL和?前的URL,所以第一?我?可以很??的做到.

2.因?有了?源URL,所以你就能很直?的猜?到用?的意?了,我??例子,就像我的?站http://www.7di.net,如果某?用?的?源URL是http://www.7di.net,而捕捉到他目前的URL是http://www.7di.net/user.php?id=1?就?明此人在??我的?站的?候???了某?人的?人?料???果找不到??人的?料?而出?,?明:ID=1的??可能不存在?已?被?掉了,那?你就要看一下?站上是否?有??URL的超?接,如果有的?就要想?法把它??掉吧!

3.??功能就比???了,只需要用PHP捕捉一下?方的ip即可.然後配合其他?站的IP?物理地址的功能就能知道此人?自哪?了.

4.??功能很好,很?大.因?我的?站www.7di.net是自己配置的服?器,所以安全方面都要靠自己??理,而往往有些不入流的?伙??人的服?器感?趣,他??用程序??各?方法??入服?器,而此?你就???你在短???收到大量的404??,且?源URL?空,他?要??的URL都是一些很敏感的URL,此?你需要做的就是打?你的防火??置,然後乾?俐落的封掉??IP.最近?段??我就是用此方法封了?十?IP,真是小兵立大功!忘??了,信息??部的IP也被我封了,我服?器在台?你????什麽?,真是的~~!

5.???,??插件??始的?候?我非常??,因?托他的福我每天?收到?百封Email,有的是因?用?正常???致的,有的是因?各家搜索引擎??集?容?致的,有些是因?小?三?想入侵?致的,?之不?其?,後?我稍作改?,把?展名符合?件或IP符合?件的都加入了??,只要?些符合?件就不用?送Email了,??一?清爽多了.

6.?一切都??不了PHP即??送Email的功能,我的做法是修改PHP.INI???PHP?部mail函??送,?然了如果你也可以用其他的方法,例如:安?sendmail或者??一?mail??藉助第三方smtp?送皆可.只要你爽就好(具???不是今天的????).

7.既然能???到???面,?明用???的URL是不存在的,所以我?要引?用?能???到正?的URL才?,那?既然是引?用???正?的URL或?你??直接用一?meta??或一句JS延?就行了何必大?周章301?向呢?因?我不想被搜索引擎??我是在作弊!回答完?.

8.?一?我在上?已??述?了,基本上?於小?三的判?要根?你的??和?你自己?站的熟悉程度??定,更有甚者,你要大??解你的?站都有哪些URL被其他?站?反?了(??啊,非一朝一夕能一蹴而就的).

??的,?放的否完了,接下?好?要上演了,把下?的代?存?404.php,然後apache或nginx之?的把你的404???指向??就行了.

<?PHP#设置URL,注意没有后划线/$MyURL = (isSet($_SERVER['HTTP_HOST'])) ? Str_iReplace('http://','',StrToLower(rTrim($_SERVER['HTTP_HOST'],'/'))) : 'www.7di.net';#设置URL,注意没有后划线/$MyDomain = (isSet($_SERVER['HTTP_HOST'])) ? 'http://'.Str_iReplace('http://','',StrToLower(rTrim($_SERVER['HTTP_HOST'],'/'))) : 'http://www.7di.net';//?定??.主要用?修正8小??差Date_Default_Timezone_Set('Etc/GMT-8');//输出头部Header('Content-type:text/html; charset=utf-8');/**	发送??	参数:		收件人,?件??(不可有?行符),?件?容(行?行之?必?用\n分隔,每行不可超?70?字符)	?明:		?用PHP?置函式Mail?送??	返回:		返回布?值	用法:		$IsSend=Fun::Mail2($email,$tit,$msg);/**/Function Mail2($to,$tit,$msg) {	IF(Filter_var($to,FILTER_VALIDATE_EMAIL)==''){		throw new Exception('??地址??!');	}	$tit='=?UTF-8?B?'.Base64_Encode($tit).'?=';	$msg = str_replace("\n.","\n..",$msg);		//Windows如果在一行开头发现一个句号则会被删掉,要避免此问题将单个句号替换成两个句号	Return Mail($to,$tit,$msg,'From:see7di@gmail.com'."\n".'Content-Type:text/html;charset=utf-8');}$msg='<table cellspacing="0" cellpadding="0" border="0"><tr><td style="padding:5px;background-color:#F57900;font-size:13px;border:2px solid #222;color:#222;">';$msg.=(isSet($_SERVER['REMOTE_ADDR'])) ? "<b>??者IP是:</b><br><a href='http://www.ip138.com/ips138.asp?ip={$_SERVER['REMOTE_ADDR']}&action=2' target='_blank'>{$_SERVER['REMOTE_ADDR']}</a><br>" : '';$msg.="<b>????:</b><br>".date('Y-m-d H:i:s',time()).'<br><br>';$msg.=(isSet($_SERVER['REMOTE_HOST'])) ? "<a href='http://www.ip138.com/ips138.asp?ip={$_SERVER['REMOTE_HOST']}&action=2' target='_blank'>{$_SERVER['REMOTE_HOST']}</a><br><br>" : '<br>';$msg.=(isSet($_SERVER['HTTP_USER_AGENT'])) ? "<b>??者???料:</b><br>{$_SERVER['HTTP_USER_AGENT']}<br><br>" : '';$msg.=(isSet($_SERVER['REQUEST_URI'])) ? "<b>要??的?面是:</b><br>{$MyDomain}{$_SERVER['REQUEST_URI']}<br><br>" : '';$msg.=(isSet($_SERVER['HTTP_REFERER']) And Trim($_SERVER['HTTP_REFERER'])!='') ? "<b>?源地址是:</b><br>{$_SERVER['HTTP_REFERER']}<br><br>" : '';$msg.='</td></tr></table>';//哪些?型的URL不?Email,如果不屏蔽掉?些的?能?死我$arr=Array('mp3','rm','swf','jpg','gif');//哪些IP不?Email,?些基本都是搜索引擎的蜘蛛$arrIP=Array('66.249.77.217','66.249.74.67');//要??的?展名$needEx=Explode('.',StrToLower(Trim($_SERVER['REQUEST_URI'])));$needEx=end($needEx);IF(!In_Array($needEx,$arr) And !In_Array(Trim($_SERVER['REMOTE_ADDR']),$arrIP)) {	Mail2('see7di@gmail.com','?自【'.$MyURL.'】的404??!',$msg);}unSet($MyURL,$msg,$needEx,$arr);Header('HTTP/1.1 301 Moved Permanently');Header ("Location:{$MyDomain}");Die();
Copy after login

  注意:如果你感?上?代?中所??的功能?不能?足你的?望,那?鼓?你改?他,完善它,加?他,我?不反?,但?你把你的作品分享?我,??啦~~~~!

?迎大家一起?我的PHP群交流切磋,??是:223494678

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Framework Security Features: Protecting against vulnerabilities. Framework Security Features: Protecting against vulnerabilities. Mar 28, 2025 pm 05:11 PM

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Customizing/Extending Frameworks: How to add custom functionality. Customizing/Extending Frameworks: How to add custom functionality. Mar 28, 2025 pm 05:12 PM

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How does session hijacking work and how can you mitigate it in PHP? How does session hijacking work and how can you mitigate it in PHP? Apr 06, 2025 am 12:02 AM

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

See all articles