SoFunction
Updated on 2025-03-08

Using 404 error page to implement UrlRewrite implementation code

Save the following code to, and then set the 404 error page to a page;

<script type="text/javascript" language="javascript"> 
var id=/(detial|show)\.asp\?id\=([0-9]+)/gi; 
var flag=/([a-z0-9_]+)\.asp\?flag\=xml/gi; 
var re_id=/(detial|show)\_([0-9]+)\.html/gi; 
var re_flag=/([a-z0-9_]+)\.rss/gi; 
var host=''; 
var ss=; 
//ss=(,host); 
var Temp=getasp(ss); 
getNotice(Temp); 

function createobj() { 
if () { 
return new ActiveXObject(""); 
} 
else if () { 
return new XMLHttpRequest(); 
} 
} 

function getNotice(url) { 
var oBao=createobj(); 
var my_url=url; 
('get',my_url,false); 
=function(){ 
if(==4){ 
if(==200){ 
var returnStr=; 
var Temps=gethtml(returnStr); 
(Temps); 
}else{ 
("The address you entered or the server 505 error was not found!"); 
} 
} 
} 
(null); 
} 

//Replace the asp URL in str as regularfunction gethtml(str){ 
var Temp_str=(id,'$1_$'); 
Temp_str=Temp_str.replace(/index\.asp/gi,''); 
Temp_str=Temp_str.replace(/myfiles\.asp/gi,''); 
Temp_str=Temp_str.replace(/mydiary\.asp\?typ\=self/gi,'mydiary_self.html'); 
Temp_str=Temp_str.replace(/mydiary\.asp/gi,''); 
Temp_str=Temp_str.replace(flag,'$'); 
Temp_str=Temp_str.replace(/xml_diary\.asp/gi,'xml_diary.html'); 
Temp_str=Temp_str.replace(/xml_download\.asp/gi,'xml_download.html'); 
Temp_str=Temp_str.replace(/xml_links\.asp/gi,'xml_links.html'); 
Temp_str=Temp_str.replace(/xml_ly\.asp/gi,'xml_ly.html'); 
Temp_str=Temp_str.replace(/ly\.asp/gi,''); 
//Temp_str=Temp_str.replace(/href=\"(http){0}/gi,'href="/'); 
return(Temp_str); 
} 

//Replace the URL with the original addressfunction getasp(str){ 
var Temp_str=(re_id,'$?id=$2'); 
Temp_str=Temp_str.replace(/index\.html/gi,''); 
Temp_str=Temp_str.replace(/myfiles\.html/gi,''); 
Temp_str=Temp_str.replace(/mydiary\.html/gi,''); 
Temp_str=Temp_str.replace(/mydiary\_self.html/gi,'?typ=self'); 
Temp_str=Temp_str.replace(/xml_diary\.html/gi,'xml_diary.asp'); 
Temp_str=Temp_str.replace(/xml_download\.html/gi,'xml_download.asp'); 
Temp_str=Temp_str.replace(/xml_links\.html/gi,'xml_links.asp'); 
Temp_str=Temp_str.replace(/xml_ly\.html/gi,'xml_ly.asp'); 
Temp_str=Temp_str.replace(/ly\.html/gi,''); 
Temp_str=Temp_str.replace(re_flag,'$?flag=xml'); 
return(Temp_str); 
} 
</script>

Generally speaking, you can only get the current 404 page URL through js. If it is asp or php, it is the URL of the 404 page, so it is better to combine js with php or asp.

For example: triggering an asp to perform some operations

<script>
var pathname = ;
("/?p="+pathname);
</script>

Note: Under normal circumstances, servers with too high permissions will not be given, and they cannot be copied and other operations.