Fork me on GitHub

Rapport de message :*
 

Re: Urls rewrtitées sous Xoops et Duplicate Content

Titre du sujet : Re: Urls rewrtitées sous Xoops et Duplicate Content
par hamoudi sur 16/03/2010 10:20:50

Citation :

Le hack redirige(depuis le .htaccess) tous les liens vers une page qui se trouve à la racine du site. Celle-ci redirige ensuite vers la destination finale..

En effet, il s'agit de la page "loadpage.php"

Citation :
Donc il faut une petite condition avec preg_match (chercher et extraire les uid, id) en php dans la page de redirection de ce hack pour voir si les utls sont du type /modules/xxxx/. si c'est le cas, il fait utiliser la même fonction que le hack pour transformer l'url et la passer à la redirection 301.

Là ça se complique, Je ne comprends plus rien...

[b]Mon fichier .htaccess se présente ainsi:

Citation :
#<Simplified URL Hack>

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^.*\.(htm|html) loadpage.php [L]
RewriteRule ^$ loadpage.php [L]

#</Simplified URL Hack>


et mon fichier loadpage.php ainsi:
Citation :

<?php

$start_module = "";

// ¤³¤Î¥Õ¥¡¥¤¥ë¤ÎURL¡£ //
// The URL of this file"loadpage.php". //

$script_path = "http://www.monsite.com/loadpage.php";

// cf. $script_path = "http://localhost/xoops/loadpage.php"; //
// //
// ¥Ç¥Ð¥Ã¥°(»È¤¦¡§1 »È¤ï¤Ê¤¤:0 ½é´üÃÍ:0) //
// Use debug? (yes:1 no:0 default:0) //

$su_debug_setting = 0;

// ------------------------------------------------------------------------ //
// °Ê²¼¤Ï´ðËÜŪ¤Ë²þÊѤ·¤Ê¤¤¤³¤È¤ò¤ª¤¹¤¹¤á¤·¤Þ¤¹¡£Don Not Change Follows //
// ------------------------------------------------------------------------ //


$discrim = '' ;
$para_str = '' ;
$file_arr = array() ;

$request = $_SERVER['REQUEST_URI'];
$sd_res = "";
$sd_res .= su_debug("REQUEST_URI" ,$request, __LINE__);
$urlpath = parse_url($script_path);
$sd_res .= su_debug("script_path" ,$script_path, __LINE__);
$script_dir = preg_replace("/(.*)\/loadpage.php/i", "\\1", $urlpath["path"]);
$dir = str_replace("@", "\/", quotemeta(str_replace("/","@", $script_dir)));
$dir2 = str_replace("@", "", quotemeta(str_replace("/","@", $script_dir)));
$sd_res .= su_debug("script_dir" ,$dir, __LINE__);
$sd_res .= su_debug("script_dir2" ,$dir2, __LINE__);
$request = preg_replace("/^".$dir."\//i", "", $request);
$sd_res .= su_debug("request" ,$request, __LINE__);

$req_arr = explode('.',$request);
if( count($req_arr) == 3 ){
$file_arr = explode('+',$req_arr[0]);
// $file_path = '';
// foreach($file_arr as $f){
// $file_path .= '/'.$f;
// }
// $file_path .= '.php';
$para_arr = explode('+',$req_arr[1]);
$para_str = '';
for($i=1;$i<=count($para_arr);$i++){
if( $i == 1 ){
$para_str .= "?".$para_arr[($i-1)]."=";
}elseif( $i % 2 == 0 ){
$para_str .= $para_arr[($i-1)];
$HTTP_GET_VARS[$para_arr[($i-2)]] = $para_arr[($i-1)];
$_GET[$para_arr[($i-2)]] = $para_arr[($i-1)];
$_REQUEST[$para_arr[($i-2)]] = $para_arr[($i-1)];
}else{
$para_str .= "&".$para_arr[($i-1)]."=";
}
}
$discrim = $req_arr[2];
}elseif( count($req_arr) == 2 ){
$file_arr = explode('+',$req_arr[0]);
// $file_path = '';
// foreach($file_arr as $f){
// $file_path .= '/'.$f;
// }
// $file_path .= '.php';
$para_str = '';
$discrim = $req_arr[1];
}

$sd_res .= su_debug("\$para_str" ,$para_str, __LINE__);


$curr_path = '';
if( $discrim == 'htm' ){
//$file_path = '/modules'.$file_path;
chdir ("modules");
$curr_path = '/modules';
}
for($i=0;$i<count($file_arr)-1;$i++){
if ( file_exists($file_arr[$i]) ) {
chdir ($file_arr[$i]);
$curr_path .= '/'.$file_arr[$i];
}
}
if ( file_exists($file_arr[$i].'.php') ) {
$script = $file_arr[$i].'.php';
$curr_path .= '/'.$file_arr[$i].'.php';
}elseif( $start_module!="" ){
for($i=0;$i<count($file_arr)-1;$i++){
chdir ("..");
}
if( $discrim != 'htm' ){
chdir ("modules");
$curr_path = '/modules';
}
if( file_exists($start_module) ){
chdir ($start_module);
$curr_path .= '/'.$start_module;
if( file_exists("index.php") ){
$script = "index.php";
$curr_path .= '/index.php';
}else{
chdir ("..");
chdir ("..");
$script = "index.php";
$curr_path = "/index.php";
}
}else{
chdir ("..");
$script = "index.php";
$curr_path = "/index.php";
}
}else{
$script = "index.php";
$curr_path = "/index.php";
}
$file_path = $curr_path;

//½ô´Ä¶­ÊÑ¿ô¤òÄêµÁ
$PHP_SELF = $script_dir.$file_path; //URI¥Ç¥£¥ì¥¯¥È¥êÉôʬ ¡Ü ¥á¥¤¥ó¥¹¥¯¥ê¥×¥È
$sd_res .= su_debug("\$PHP_SELF" ,$PHP_SELF, __LINE__);

$HTTP_SERVER_VARS['SCRIPT_NAME'] = $script_dir.$file_path; //URI¥Ç¥£¥ì¥¯¥È¥êÉôʬ ¡Ü ¥á¥¤¥ó¥¹¥¯¥ê¥×¥È
$HTTP_SERVER_VARS['REQUEST_URI'] = $script_dir.$file_path.$para_str; //URI¥Ç¥£¥ì¥¯¥È¥êÉôʬ ¡Ü ¥á¥¤¥ó¥¹¥¯¥ê¥×¥È ¡Ü ¥Ñ¥é¥á¡¼¥¿
$HTTP_SERVER_VARS['PHP_SELF'] = $script_dir.$file_path; //URI¥Ç¥£¥ì¥¯¥È¥êÉôʬ ¡Ü ¥á¥¤¥ó¥¹¥¯¥ê¥×¥È
$HTTP_SERVER_VARS['QUERY_STRING'] = preg_replace('/^\?/','',$para_str);
$HTTP_SERVER_VARS["SCRIPT_FILENAME"] = $_SERVER['DOCUMENT_ROOT'] .$dir2.$file_path;
$HTTP_SERVER_VARS["PATH_TRANSLATED"] = $_SERVER['DOCUMENT_ROOT'] .$dir2.$file_path;
$sd_res .= su_debug("\$HTTP_SERVER_VARS['SCRIPT_NAME']" ,$HTTP_SERVER_VARS['SCRIPT_NAME'], __LINE__);
$sd_res .= su_debug("\$HTTP_SERVER_VARS['REQUEST_URI']" ,$HTTP_SERVER_VARS['REQUEST_URI'], __LINE__);
$sd_res .= su_debug("\$HTTP_SERVER_VARS['PHP_SELF']" ,$HTTP_SERVER_VARS['PHP_SELF'], __LINE__);
$sd_res .= su_debug("\$HTTP_SERVER_VARS['QUERY_STRING']" ,$HTTP_SERVER_VARS['QUERY_STRING'], __LINE__);
$sd_res .= su_debug("\$HTTP_SERVER_VARS['SCRIPT_FILENAME']" ,$HTTP_SERVER_VARS['SCRIPT_FILENAME'], __LINE__);
$sd_res .= su_debug("\$HTTP_SERVER_VARS['PATH_TRANSLATED']" ,$HTTP_SERVER_VARS['PATH_TRANSLATED'], __LINE__);
$_SERVER['SCRIPT_NAME'] = $script_dir.$file_path;
$_SERVER['REQUEST_URI'] = $script_dir.$file_path.$para_str;
$_SERVER['PHP_SELF'] = $script_dir.$file_path;
$_SERVER['QUERY_STRING'] = preg_replace('/^\?/','',$para_str);
$_SERVER["SCRIPT_FILENAME"] = $_SERVER['DOCUMENT_ROOT'] .$dir2.$file_path;
$_SERVER["PATH_TRANSLATED"] = $_SERVER['DOCUMENT_ROOT'] .$dir2.$file_path;
$sd_res .= su_debug("\$_SERVER['SCRIPT_NAME']" ,$_SERVER['SCRIPT_NAME'], __LINE__);
$sd_res .= su_debug("\$_SERVER['REQUEST_URI']" ,$_SERVER['REQUEST_URI'], __LINE__);
$sd_res .= su_debug("\$_SERVER['PHP_SELF']" ,$_SERVER['PHP_SELF'], __LINE__);
$sd_res .= su_debug("\$_SERVER['QUERY_STRING']" ,$_SERVER['QUERY_STRING'], __LINE__);
$sd_res .= su_debug("\$_SERVER['SCRIPT_FILENAME']" ,$_SERVER['SCRIPT_FILENAME'], __LINE__);
$sd_res .= su_debug("\$_SERVER['PATH_TRANSLATED']" ,$_SERVER['PATH_TRANSLATED'], __LINE__);
$HTTP_ENV_VARS['SCRIPT_NAME'] = $script_dir.$file_path;
$HTTP_ENV_VARS['REQUEST_URI'] = $script_dir.$file_path.$para_str;
$HTTP_ENV_VARS['PHP_SELF'] = $script_dir.$file_path;
$HTTP_ENV_VARS["SCRIPT_FILENAME"] = $_SERVER['DOCUMENT_ROOT'] .$dir2.$file_path;
$sd_res .= su_debug("\$HTTP_ENV_VARS['SCRIPT_NAME']" ,$HTTP_ENV_VARS['SCRIPT_NAME'], __LINE__);
$sd_res .= su_debug("\$HTTP_ENV_VARS['REQUEST_URI']" ,$HTTP_ENV_VARS['REQUEST_URI'], __LINE__);
$sd_res .= su_debug("\$HTTP_ENV_VARS['PHP_SELF']" ,$HTTP_ENV_VARS['PHP_SELF'], __LINE__);
$sd_res .= su_debug("\$HTTP_ENV_VARS['SCRIPT_FILENAME']" ,$HTTP_ENV_VARS['SCRIPT_FILENAME'], __LINE__);
$GLOBALS["PATH_TRANSLATED"] = $_SERVER['DOCUMENT_ROOT']. $dir2.$file_path;
$GLOBALS["SCRIPT_FILENAME"] = $_SERVER['DOCUMENT_ROOT']. $dir2.$file_path;
$sd_res .= su_debug("\$GLOBALS['PATH_TRANSLATED']" ,$GLOBALS['PATH_TRANSLATED'], __LINE__);
$sd_res .= su_debug("\$GLOBALS['SCRIPT_FILENAME']" ,$GLOBALS['SCRIPT_FILENAME'], __LINE__);
$_ENV['SCRIPT_NAME'] = $script_dir.$file_path;
$_ENV['REQUEST_URI'] = $script_dir.$file_path.$para_str;
$_ENV['PHP_SELF'] = $script_dir.$file_path;
$_ENV["SCRIPT_FILENAME"] = $_SERVER['DOCUMENT_ROOT'] .$dir2.$file_path;
$sd_res .= su_debug("\$_ENV['SCRIPT_NAME']" ,$_ENV['SCRIPT_NAME'], __LINE__);
$sd_res .= su_debug("\$_ENV['REQUEST_URI']" ,$_ENV['REQUEST_URI'], __LINE__);
$sd_res .= su_debug("\$_ENV['PHP_SELF']" ,$_ENV['PHP_SELF'], __LINE__);
$sd_res .= su_debug("\$_ENV['SCRIPT_FILENAME']" ,$_ENV['SCRIPT_FILENAME'], __LINE__);


$SCRIPT_FILENAME = $_SERVER['DOCUMENT_ROOT'].$dir2.$file_path;
$sd_res .= su_debug("\$SCRIPT_FILENAME" ,$SCRIPT_FILENAME, __LINE__);
$SCRIPT_NAME = $script_dir.$file_path;
$sd_res .= su_debug("\$SCRIPT_NAME" ,$SCRIPT_NAME, __LINE__);


include $script; //¥¹¥¯¥ê¥×¥ÈÆɤ߹þ¤ß

if( $su_debug_setting == 1 ){
echo "<b>* Simplified URLs Hack debug start</b><br />";
echo $sd_res;
}

exit;

function su_debug($title, $message, $line)
{
global $su_debug_setting;
if( $su_debug_setting == 1 ){
if(is_array($message)){
$message_put = "array(";
foreach($message as $k => $v){
$message_put .= "[$k]=>\"$v\"&nbsp;&nbsp;" ;
}
$message_put .= ")";
$message = $message_put;
}
// echo "<b>$title</b>:\"$message\" line:<b>$line</b><br />";
return "<b>$title</b>:\"$message\" line:<b>$line</b><br />";
}
}
?>



Merci pour votre aide...
Propulsé avec XOOPS | Graphisme adapté par Tatane, Grosdunord, Montuy337513

36 Personne(s) en ligne (22 Personne(s) connectée(s) sur Forum) | Utilisateur(s): 0 | Invité(s): 36 | Plus ...