Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    problema irrisolto col REWRITE

    ho installato un rewrite su cutenews seguendo una guida, però c'è un piccolissimo problema, nella home il mio indirizzo diventa:

    www.miosito.com/news/titolo.html

    ma se io applico lo stesso php di cutenews nelle altre pagine che hanno un pezzo di indirizzo in più diventa

    www.miosito.com/PARTE_DI_TROPPO/news/titolo.html

    e quindi mi trova pagina bianca...., come posso eliminare quella parte di troppo ?




    questo è il mio codice del rewrite sul .htaccess

    RewriteEngine On
    RewriteBase /

    RewriteRule ^news/(.*).html(.*)$ full.php?subaction=showfull&url=$1$2 [L,NC]
    RewriteRule ^postpage/(.*).html(.*)$ index.php?start_from=$1$2 [L,NC]

    RewriteRule ^comments/(.*).html(.*)$ full.php?subaction=showcomments&url=$1$2 [L,NC]
    RewriteRule ^commentspage/(.*)/(.*).html(.*)$ index.php?comm_start_from=$1&subaction=showcomment s&url=$2$3 [L,NC]

    RewriteRule ^archiveindex/(.*).html(.*)$ index.php?archive=$1&subaction=list-archive$2 [L,NC]
    RewriteRule ^archive/(.*).html(.*)$ index.php?subaction=showfull&url=$1$2 [L,NC]
    RewriteRule ^archivepage/(.*)/(.*).html(.*)$ index.php?start_from=$2&archive=$1&subaction=list-archive$3 [L,NC]





    QUESTO è il codice PHP INSERITO NELLE MIE PAGINE

    <?PHP
    //Mod_rewrite start
    ob_start();
    $path_to_data = "http://www.miosito.com/news/data";
    $url = $_GET['url'];
    $test = find_archive(title_to_id($url));
    $id = title_to_id($url);
    $ucat = title_to_ucat($url);
    //Mod_rewrite end
    $number = 12;
    include("../news/show_news.php");
    //Mod_rewrite start



    function replace_title($title){
    $letter_replacements = array('^' => 'oe', '?' => 'ae');

    $result = strtolower(strip_tags(html_entity_decode($title))) ;

    $result = strtr($result, $letter_replacements);

    $result = preg_replace('/\W/', "-", strip_tags($result));



    return $result;

    }



    function title_to_id($title){

    global $path_to_data;



    if($handle = opendir($path_to_data."/archives"))

    while (false !== ($file = readdir($handle))){

    if($file != "." and $file != ".." and eregi("news", $file)){

    $files_arch[] = $path_to_data."/archives/$file";

    }

    }

    $files_arch[] = $path_to_data."/news.txt";



    foreach($files_arch as $file){

    $all_news = file($file);

    foreach($all_news as $news_line){

    $news_arr = explode("|", $news_line);

    if(replace_title($news_arr[2]) == $title){



    return $news_arr[0];

    }

    }

    }

    }



    function title_to_ucat($title){

    global $path_to_data;

    $all_news = file($path_to_data."/news.txt");

    foreach($all_news as $news_line){

    $news_arr = explode("|", $news_line);

    if(replace_title($news_arr[2]) == $title){

    return $news_arr[6];

    }

    }

    }



    function find_archive($id){

    global $path_to_data;



    if($handle = opendir($path_to_data."/archives"))

    while (false !== ($file = readdir($handle))){

    if($file != "." and $file != ".." and eregi("news", $file)){

    $files_arch[] = $path_to_data."/archives/$file";

    }

    }

    $files_arch[] = $path_to_data."/news.txt";



    foreach($files_arch as $file){

    $all_news_db = file("$file");

    foreach($all_news_db as $news_line){

    $news_arr = explode("|", $news_line);

    if($news_arr[0] == $id){

    if(ereg("([[:digit:]]{0,})\.news\.arch", $file, $regs)){ $archive = $regs[1]; }

    return $archive;

    }

    }

    }

    }
    function id_to_title($id, $archiv = false, $type, $page = ''){
    global $path_to_data;
    if($archiv){
    $all_news = file($path_to_data."/archives/".$archiv.".news.arch");
    }
    else{
    $all_news = file($path_to_data."/news.txt");
    }
    foreach($all_news as $news_line){
    $news_arr = explode("|", $news_line);
    if($news_arr[0] == $id){
    $title = replace_title($news_arr[2]);
    if($type == "commentspage"){
    return "commentspage/".$page."/".$title.".html";
    }
    else
    return $type."/".$title.".html";
    }
    }
    }
    $show_news = ob_get_contents();
    ob_get_clean();
    $script_file = end($script_url = explode("/", $HTTP_SERVER_VARS['SCRIPT_NAME']));
    $path = substr($HTTP_SERVER_VARS['SCRIPT_NAME'], 0, -strlen($script_file));
    $find = array( /*news*/ "#".$script_file."\?subaction=showfull&amp;id=(.*? )&amp;archive=&amp;start_from=&amp;ucat=(.*?)&amp; #ie",
    /*postcomments*/ "#".$script_file."\?subaction=showcomments&amp;id= (.*?)&amp;archive=&amp;start_from=&amp;ucat=(.*?)& amp;#ie",
    /*postpage*/ "#".$script_file."\?start_from=(.*?)&amp;ucat=&amp ;archive=&amp;subaction=&amp;id=(.*?)&amp;#i",
    /*archiveindex*/ "#".$script_file."\?archive=(.*?)&subaction=li st-archive#i",
    /*archive*/ "#".$script_file."\?subaction=showfull&amp;id=(.*? )&amp;archive=(.*?)&amp;start_from=&amp;ucat=(.*?) &amp;#ie",
    /*archivepage*/ "#".$script_file."\?start_from=(.*?)&amp;ucat=&amp ;archive=(.*?)&amp;subaction=list-archive&amp;id=&amp;#i",
    /*archivecomments*/ "#".$script_file."\?subaction=showcomments&amp;id= (.*?)&amp;archive=(.*?)&amp;start_from=&amp;ucat=( .*)&amp;#ie",
    /*searchnews*/ "#".$script_file."\?misc=search&subaction=showfull &id=(.*?)&archive=&cnshow=news&ucat=(.*?)&start_fr om=&#ie",
    /*searcharchives*/ "#".$script_file."\?misc=search&subaction=showfull &id=(.*?)&archive=(.*?)&cnshow=news&ucat=(.*?)&sta rt_from=&#ie",
    /*ncommentspage*/ "#".$script_file."\?comm_start_from=(.*?)&amp;arch ive=&amp;subaction=showcomments&amp;id=(.*?)&amp;u cat=(.*?)&amp;#ie",
    /*acommentspage*/ "#".$script_file."\?comm_start_from=(.*?)&amp;arch ive=(.*?)&amp;subaction=showcomments&amp;id=(.*?)& amp;ucat=(.*?)&amp;#ie",
    );
    $replace = array( "id_to_title('\\1', false, 'news')",
    "id_to_title('\\1', false, 'comments')",
    "postpage/\\1.html",
    "archiveindex/\\1.html",
    "id_to_title('\\1', '\\2', 'archive')",
    "archivepage/\\2/\\1.html",
    "id_to_title('\\1', '\\2', 'comments')",
    "id_to_title('\\1', false, 'news')",
    "id_to_title('\\1', '\\2', 'archive')",
    "id_to_title('\\2', false, 'commentspage', '\\1')",
    "id_to_title('\\3', '\\2', 'commentspage', '\\1')",
    );
    $show_news = preg_replace($find, $replace, $show_news);
    $show_news = str_replace("&url=".$url, '', $show_news);
    if(!file_exists('.htaccess')){
    $htaccess = "RewriteEngine On\n";
    $htaccess .= "RewriteBase ".$path."\n\n";
    $htaccess .= "RewriteRule ^news/(.*).html(.*)$ ".$script_file."?subaction=showfull&url=$1$2 [L,NC]\n";
    $htaccess .= "RewriteRule ^postpage/(.*).html(.*)$ ".$script_file."?start_from=$1$2 [L,NC]\n\n";
    $htaccess .= "RewriteRule ^comments/(.*).html(.*)$ ".$script_file."?subaction=showcomments&url=$1 $2 [L,NC]\n";
    $htaccess .= "RewriteRule ^commentspage/(.*)/(.*).html(.*)$ ".$script_file."?comm_start_from=$1&subaction=show comments&url=$2$3 [L,NC]\n\n";
    $htaccess .= "RewriteRule ^archiveindex/(.*).html(.*)$ ".$script_file."?archive=$1&subaction=list-archive$2 [L,NC]\n";
    $htaccess .= "RewriteRule ^archive/(.*).html(.*)$ ".$script_file."?subaction=showfull&url=$1$2 [L,NC]\n";
    $htaccess .= "RewriteRule ^archivepage/(.*)/(.*).html(.*)$ ".$script_file."?start_from=$2&archive=$1&subactio n=list-archive$3 [L,NC]";
    $file = fopen(".htaccess", "w");
    fwrite($file, $htaccess);
    fclose($file);
    }
    echo $show_news;
    //Mod_rewrite end
    ?>

  2. #2
    ragazzi è impossibile ?

    se non è possibile ditemelo, almeno non ci provo più...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.