Fork me on GitHub

Rapport de message :*
 

Re: Comment faire fonctionner l'url rewriting pour myalbum ?

Titre du sujet : Re: Comment faire fonctionner l'url rewriting pour myalbum ?
par JavaCup sur 05/03/2008 15:22:24

Bonjour,

le plus important c'est de comprendre le principe et d'avoir correctement installer le hack kenogui

hack kenogui a telecharger :ici


L'installation :

Dans le header =>

Avant la ligne de :

defined("XOOPS_ROOT_PATH") or die( 'XOOPS root path not defined' );


mettre :

//kenogui - mod rewrite ---------------------------------------
// bandwidth saving - escape cross indexing with/without WWW
include('SubDomainProtect.php');
//opening the buffer and call the mod
ob_start();
include(
'ModRegExp.php');
//-- end hack --------------------------------------------------

et apres cette ligne :

$xoopsTpl->assign_by_ref'xoBlocks'$aggreg->blocks );

mettre :

//kenogui HACK -- rewrite urls in main block (module in fact) before putting it in cache file
$rewrittenContent=replace_for_mod_rewrite($xoopsTpl->fetch($xoopsCachedTemplate$xoopsCachedTemplateId));
$xoopsTpl->assign('xoops_contents'$rewrittenContent);
$xoopsTpl->assign('xoops_contents'$xoopsTpl->fetch($xoopsCachedTemplate$xoopsCachedTemplateId));
//--- end hack -------------------------------------------------------------------------------


et avant cette ligne :

if ( $xoopsModule ) {
        
$xoTheme->contentCacheLifetime = @$xoopsConfig['module_cache'][ $xoopsModule->getVar('mid''n') ];
    }


Mettre :

//kenogui HACK -- rewrite urls in every side blocks before putting them in cache file
$bcontent=replace_for_mod_rewrite($bcontent);
//--- fin hack ----------------------------------------------------------------------


Dans le footer.php =>

a la fin du code avant "?>"

mettre :

//kenogui - mod rewrite --
//store buffer in $rewrite
$rewrite ob_get_contents();
// delete output buffer and stop buffering
ob_end_clean();
//display modified buffer to screen
echo replace_for_mod_rewrite($rewrite);
ob_end_flush();
//-- end hack -----------



Apres tu dois mettre sur la racine de ton site les 3 fichier .htaccess, ModRegExp.php, SubDomainProtect.php

dans SubDomainProtect.php

tu modifie par le nom de ton site : $url="http://www.YOUR-SITE.com";


Bon pour l'exemple de http://www.tonsite.com/modules/myalbum/photo.php?lid=1
on va essayer de la mettre en url rewrite tel : http://www.tonsite.com/mon-album/photo-1.html

A la racine du site :

dans le fichier ModRegExp.php :

function replace_for_mod_rewrite(&$s)
{    
    
    
$urlin = array( 

    
"'(?<!//)modules/myalbum/"'",
    "'
(?<!//)modules/myalbum/photo.php?lid=([0-9]*)"'",

    
);

    
$urlout = array(
    
"mon-album/"",
    "
mon-album/photo-\1.html"",

    );

    
$s preg_replace($urlin$urlout$s);
    return 
$s;
}


dans le fichier .htaccess :

RewriteRule ^mon-album/$  modules/myalbum/  [L]


RewriteRule ^modules/myalbum/photo-([0-9]+).html$   modules/myalbum/photo.php?lid=$1    [L]



A la racine du module myalbum tu recopiera les 2 fichier ModRegExp.php et .htaccess


dans le ModRegExp.php ca sera :

function replace_for_mod_rewrite(&$s)
{    
    
    
$urlin = array( 

    
"'(?<!//)myalbum/"'",
    "'
(?<!//)photo.php?lid=([0-9]*)"'",
    

    
);

    
$urlout = array(
    
"../../mon-album/"",
    "
../../mon-album/photo-\1.html"",

    );

    
$s preg_replace($urlin$urlout$s);
    return 
$s;
}


dans le .htaccess :

RewriteRule ^photo-([0-9]+).html$   photo.php?lid=$1    [L]



voila ceci en complement du tutos de Ash tu va pouvoir t'en sortir

bonne chance
Propulsé avec XOOPS | Graphisme adapté par Tatane, Grosdunord, Montuy337513

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