Afficher adresse page d'accueil

Description

Ceci est petit script pas génial mais qui est très serviable dans les erreurs 404
En fait c'est une page 404 avec un lien vers la page d'accueil
en fait il affiche l'adresse de la page d'accueil du site en lien.

Source / Exemple :


<php
   include "zip, zip, zip";
?>

merci de prendre le zip mais si c'est vraiment non :

Mais vous pouvez suivre le code ici :
Avec . htaccess
----------------
.htaccess :

ErreurDocument 404 erreur404.html

erreur404.html :

<html>
 <head>
<script> 

function Homepage(){

<!--

// in real bits, urls get returned to our script like this:

// res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm 

	//For testing use DocURL = "res://shdocvw.dll/http_404.htm#https://www.microsoft.com/bar.htm"

	DocURL = document.URL;

		

	//this is where the http or https will be, as found by searching for :// but skipping the res://

	protocolIndex=DocURL.indexOf("://",4);

	

	//this finds the ending slash for the domain server 

	serverIndex=DocURL.indexOf("/",protocolIndex + 3);

		//for the href, we need a valid URL to the domain. We search for the # symbol to find the begining 

	//of the true URL, and add 1 to skip it - this is the BeginURL value. We use serverIndex as the end marker.

	//urlresult=DocURL.substring(protocolIndex - 4,serverIndex);

	BeginURL=DocURL.indexOf("#",1) + 1;

	

	urlresult=DocURL.substring(BeginURL,serverIndex);

				

	//for display, we need to skip after http://, and go to the next slash

	displayresult=DocURL.substring(protocolIndex + 3 ,serverIndex);

	InsertElementAnchor(urlresult, displayresult);

}

function HtmlEncode(text)
{
    return text.replace(/&/g, '&amp').replace(/'/g, '&quot;').replace(/</g, '<').replace(/>/g, '>');
}

function TagAttrib(name, value)
{
    return ' '+name+'="'+HtmlEncode(value)+'"';
}

function PrintTag(tagName, needCloseTag, attrib, inner){
    document.write( '<' + tagName + attrib + '>' + HtmlEncode(inner) );
    if (needCloseTag) document.write( '</' + tagName +'>' );
}

function URI(href)
{
    IEVer = window.navigator.appVersion;
    IEVer = IEVer.substr( IEVer.indexOf('MSIE') + 5, 3 );

    return (IEVer.charAt(1)=='.' && IEVer >= '5.5') ?
        encodeURI(href) :
        escape(href).replace(/%3A/g, ':').replace(/%3B/g, ';');
}

function InsertElementAnchor(href, text)
{
    PrintTag('A', true, TagAttrib('HREF', URI(href)), text);
}

//-->

</script>

 </head>
 <body>
  <p align="center"><font color="#FF0000"><h1><u>404 not found</u></h1></font></p><br>// écrire 404 not found
  <p align="left"><font color="#FF0000"><h2>La page est introuvable</h2></font></p><br><br>
  <span style="color: #ff0000">La page d'accueil de ce site est  <script>

	  <!--

	  if (!((window.navigator.userAgent.indexOf("MSIE") > 0) && (window.navigator.appVersion.charAt(0) == "2")))page

	  { 

	  	Homepage();

	  }

	  //-->

	   </script>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p align="left"><font color="#FF0000"><h7>Affichage de la page d'accueil sans .htaccess Code écrit par Cédric Denotte</h7></font><br>
<font color="#FF0000"><h7>Copyright 26/12/2006</h7></font><br>
<font color="#FF0000"><h7><a href="http://www.cdd-pro.com">http://www.cdd-pro.com</a> | <a href="mailto:cdd@cdd-pro.com">cdd@cdd-pro.com</a></h7></font><br>
<font color="#FF0000"><h7>E-mail et site web valide à partir du 28/12/2006 Sinon <a href="mailto:cedric_denotte@msn.com">cedric_denotte@msn.com</a></h7></font></p>
</body>
</html>

-------------------------------------------------------------------------------------------------------------------------
Sans .htaccess
---------------

index.html :

<html>

 <head>
<script> 

function Homepage(){

<!--

// in real bits, urls get returned to our script like this:

// res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm 

	//For testing use DocURL = "res://shdocvw.dll/http_404.htm#https://www.microsoft.com/bar.htm"

	DocURL = document.URL;

		

	//this is where the http or https will be, as found by searching for :// but skipping the res://

	protocolIndex=DocURL.indexOf("://",4);

	

	//this finds the ending slash for the domain server 

	serverIndex=DocURL.indexOf("/",protocolIndex + 3);

		//for the href, we need a valid URL to the domain. We search for the # symbol to find the begining 

	//of the true URL, and add 1 to skip it - this is the BeginURL value. We use serverIndex as the end marker.

	//urlresult=DocURL.substring(protocolIndex - 4,serverIndex);

	BeginURL=DocURL.indexOf("#",1) + 1;

	

	urlresult=DocURL.substring(BeginURL,serverIndex);

				

	//for display, we need to skip after http://, and go to the next slash

	displayresult=DocURL.substring(protocolIndex + 3 ,serverIndex);

	InsertElementAnchor(urlresult, displayresult);

}

function HtmlEncode(text)
{
    return text.replace(/&/g, '&amp').replace(/'/g, '&quot;').replace(/</g, '<').replace(/>/g, '>');
}

function TagAttrib(name, value)
{
    return ' '+name+'="'+HtmlEncode(value)+'"';
}

function PrintTag(tagName, needCloseTag, attrib, inner){
    document.write( '<' + tagName + attrib + '>' + HtmlEncode(inner) );
    if (needCloseTag) document.write( '</' + tagName +'>' );
}

function URI(href)
{
    IEVer = window.navigator.appVersion;
    IEVer = IEVer.substr( IEVer.indexOf('MSIE') + 5, 3 );

    return (IEVer.charAt(1)=='.' && IEVer >= '5.5') ?
        encodeURI(href) :
        escape(href).replace(/%3A/g, ':').replace(/%3B/g, ';');
}

function InsertElementAnchor(href, text)
{
    PrintTag('A', true, TagAttrib('HREF', URI(href)), text);
}

//-->

</script>

 </head>
 <body>
  <span style="color: #ff0000">La page d'accueil de ce site est  <script>

	  <!--

	  if (!((window.navigator.userAgent.indexOf("MSIE") > 0) && (window.navigator.appVersion.charAt(0) == "2")))

	  { 

	  	Homepage();

	  }

	  //-->

	   </script>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p align="left"><font color="#FF0000"><h7>Affichage de la page d'accueil sans .htaccess Code écrit par Cédric Denotte</h7></font><br>
<font color="#FF0000"><h7>Copyright 26/12/2006</h7></font><br>
<font color="#FF0000"><h7><a href="http://www.cdd-pro.com">http://www.cdd-pro.com</a> | <a href="mailto:cdd@cdd-pro.com">cdd@cdd-pro.com</a></h7></font><br>
<font color="#FF0000"><h7>E-mail et site web valide à partir du 28/12/2006 Sinon <a href="mailto:cedric_denotte@msn.com">cedric_denotte@msn.com</a></h7></font></p>

</body>
</html>
-------------------------------------------------------------------------------------------------------------------------
Merci plutot de télécharger le zip

Conclusion :


Si je trouves des amériotations encore mieux je vous les envois tout de suite !!!
biento une adresse d'exemple.

~mon site~ http://www.cdd-pro.com

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.