Script de redirection sans tenir compte...........

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : Script de redirection sans tenir compte...........

par Pingwin » 23 mars 2007, 19:12

Ca fonctionne!!! Merci beaucoup!
Voici le code (au cas au quelqu'un d'autre aurait le même pb)
<?php
$provenance = $_SERVER["REQUEST_URI"];
if(strpos($_SERVER["REQUEST_URI"], "&PHPSESSID=") <> FALSE)
$url = preg_replace('/&PHPSESSID=.+/', '', $provenance);
else $url = $_SERVER["REQUEST_URI"];

header("HTTP/1.1 301 Moved Permanently");
if($url === "/articles.php?lng=fr&pg=48")
header("Location: http://wiki.linux-aide.org/index.php?n= ... CeQueLinux");
if($url === "/articles.php?lng=fr&pg=574")
header("Location: http://wiki.linux-aide.org/index.php?n= ... onHistoire");
if($url === "/articles.php?lng=fr&pg=549")
header("Location: http://wiki.linux-aide.org/index.php?n= ... LaMascotte");
...................
................
.................
Merci beaucoup!

par AB » 23 mars 2007, 13:14

Bonjour,

Pour enlever le PHPSESSID en fin d'url :
$provenance = $_SERVER["REQUEST_URI"]; 

$url = preg_replace('/&PHPSESSID=.+/', '', $provenance);

par Bluebird75 » 23 mars 2007, 12:40

Salut!
Sauf que le problème vient du fait que le PHPSESSID est variable, et que je ne peux pas le désactiver avec guppy, sinon "Internal Server error"... Il faudrait donc une fonction qui supprime &PHPSESSID= et tout ce qui le suit, ce que je n'ai pas trouvé dans la fiche sur ereg...

par raptor » 23 mars 2007, 08:08

L'astuce serait de créer une variable style
$provenance = $_SERVER["REQUEST_URI"];

Sur cette variable, tu lance un ereg_replace visant a remplacer &PHPSESSID=56465464545555 par rien, et ensuite tu fais tes "if" non pas sur $_SERVER["REQUEST_URI"] mais sur $provenance.

par Pingwin » 22 mars 2007, 22:38

Personne n'a d'idée???

Script de redirection sans tenir compte...........

par Pingwin » 21 mars 2007, 21:07

Bonjour!
Je voudrais faire un script de redirection qui ne tient pas compte de PHPSESSID=.
Je vous explique: Voulant remplacer mon ancien site http://www.linux-aide.org par http://wiki.linux-aide.org, sans déstabiliser les visiteurs/robots, j'ai fait un petit script PHP qui à chaque page de l'ancien site, associait la redirection vers la nouvelle page:
<?php
header("HTTP/1.1 301 Moved Permanently");
if($_SERVER["REQUEST_URI"] === "/articles.php?lng=fr&pg=48")
header("Location: http://wiki.linux-aide.org/index.php?n= ... CeQueLinux");
if($_SERVER["REQUEST_URI"] === "/articles.php?lng=fr&pg=574")
header("Location: http://wiki.linux-aide.org/index.php?n= ... onHistoire");
if($_SERVER["REQUEST_URI"] === "/articles.php?lng=fr&pg=549")
header("Location: http://wiki.linux-aide.org/index.php?n= ... LaMascotte");
Seul problème, lorsqu'un PHPSESSID est associé à la page, comme par exemple sur des liens référencés dans google ou dans des favoris de visiteurs, le script ne marche plus.
Comment faut il donc faire pour ne pas tenir compte de PHPSESSID?
J'ai essayé le script suivant mais sans succès.......
<?php
header("HTTP/1.1 301 Moved Permanently");
if(strpos($_SERVER["REQUEST_URI"], "articles.php?lng=fr&pg=48") <> FALSE)
header("Location: http://wiki.linux-aide.org/index.php?n= ... CeQueLinux");
if(strpos($_SERVER["REQUEST_URI"], "/articles.php?lng=fr&pg=574") != false)
header("Location: http://wiki.linux-aide.org/index.php?n= ... onHistoire");
if(strpos($_SERVER["REQUEST_URI"], "/articles.php?lng=fr&pg=549") !=FALSE)
header("Location: http://wiki.linux-aide.org/index.php?n= ... LaMascotte");
Avez vous une idée pour résoudre mon problème?
Merci d'avance
Bonne soirée!