Vérifier une redirection 301 : comment faire ?

WRInaute occasionnel
WRInaute passionné
sunnmagic a dit:
Il y a 302 en haut... c'est donc 301 ou 302 ??
302... pas de bol

Ou un petit script php avec la bibliothèque CURL

Code:
// Récupération code statut HTTP
function getHTTPHeaders($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 1); // Inclure l'entête HTTP
curl_setopt($ch, CURLOPT_NOBODY, 1); // Ne pas télécharger le corps
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Ne pas afficher, mais retourner le résultat de curl_exec
return split("\n",curl_exec($ch));
}
$code = getHTTPHeaders($url);
echo $code[0]; // pour le statut
 
WRInaute occasionnel
Ahhh, j'ai mis
Code:
header("Status: 301 Moved Permanently", false, 301);

au lieu de
Code:
header("Status: 301 Moved Permanently");

Et j'obtiens :

Code:
HTTP/1.1 301 Moved Permanently
Date: Fri, 01 Jun 2007 09:30:12 GMT
Server: Apache
X-Powered-By: PHP/4.3.9
Status: 301 Moved Permanently
Location: http://www.play3-live.com/news-ps3-gunda
m-muso-3582.html
Content-Length: 0
Connection: close
Content-Type: text/html; charset=ISO-8859-1


C'est donc correct cette fois-si ??
 
WRInaute passionné
Code:
RedirectPermanent /blabla/index.html http://www.exemple.com/toto/bidule.html
ou
Code:
RewriteRule ^blabla/index.html /toto/bidule.html [R=301]
 
WRInaute occasionnel
Merci :)

Et ta solution avec le .htaccess est applicable quand il y a des paramètres, sachant que l'ancienne page est déjà rewritée ? ($1, ([0-9]+),...)
 
Discussions similaires
Haut