Dleshka.org
Авторизация

Хак Убираем ID в полной новости / DLE 8.х - 10.x

+1
TipTop 16-12-2013 Хаки DLE 0 комментариев
Хак убирает ID вставку и переадресует со старых адресов новостей на новые. Так как новости автоматически присваивается ID, который в последствии вставляется в URL адрес новости что для СЕО не желательно. Работает со всеми версиями движка, начиная с DLE 8.5.

Автор: Gameer
DLE: 8.х - 10.x

Несколько действий

1) Открыть /engine/engine.php найти:

// ################ Новость целиком #################
            if ($subaction != '' or $newsid) {
                if (! $newsid) $sql_news = "SELECT * FROM " . PREFIX . "_post LEFT JOIN " . PREFIX . "_post_extras ON (" . PREFIX . "_post.id=" . PREFIX . "_post_extras.news_id) WHERE alt_name ='$news_name' AND date >= '{$year}-{$month}-{$day}' AND date < '{$year}-{$month}-{$day}' + INTERVAL 24 HOUR LIMIT 1";
                else $sql_news = "SELECT * FROM " . PREFIX . "_post LEFT JOIN " . PREFIX . "_post_extras ON (" . PREFIX . "_post.id=" . PREFIX . "_post_extras.news_id) WHERE  id = '{$newsid}'";
                
                if ($subaction == '') $subaction = "showfull";
            }
        }


Заменить на:

$full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
                
                } else {
                    
                    $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
                
                }
            
            } else {
                
                $full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
            }
        
        } else {


            
            $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
        
        }


2) Открыть в папке /engine/modules файлы show.short.php; show.custom.php; topnews.php, search.php и найти:

$config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
                
                } else {
                    
                    $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
                
                }
            
            } else {
                
                $full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
            }
        
        } else {
            
            $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
        
        }


Заменить на:

$full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['alt_name'] . ".html";
                } else {
                    $full_link = $config['http_home_url'] . $row['alt_name'] . ".html";
                }    
            } else {        
                $full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
            }        
        } else {
            $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['alt_name'];
        }


3) Открыть в папке /engine/classes/comments.class.php и найти

$full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['post_id'] . "-" . $row['alt_name'] . ".html";
                        
                        } else {
                            
                            $full_link = $config['http_home_url'] . $row['post_id'] . "-" . $row['alt_name'] . ".html";
                        
                        }
                    
                    } else {
                        
                        $full_link = $config['http_home_url'] . date( 'Y/m/d/', strtotime ($row['newsdate']) ) . $row['alt_name'] . ".html";
                    }
                
                } else {
                    
                    $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['post_id'];
                
                }


И заменить на:

$full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['alt_name'] . ".html"; 
                        
                        } else {
                            
                        $full_link = $config['http_home_url'] . $row['alt_name'] . ".html";
                        
                        }
                    
                    } else {
                        
                        $full_link = $config['http_home_url'] . date( 'Y/m/d/', strtotime ($row['newsdate']) ) . $row['alt_name'] . ".html";
                    }
                
                } else {
                    
                    $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['alt_name']; 
                
                }


4. Открываем главный файл .htaccess и ищем:

# Сам пост
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),([0-9]+),(.*).html(/?)+$ index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&cstart=$5&news_name=$6&seourl=$6 [L]
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),(.*).html(/?)+$ index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5&seourl=$5 [L]
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/print:page,([0-9]+),(.*).html(/?)+$ engine/print.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5&seourl=$5 [L]
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*).html(/?)+$ index.php?subaction=showfull&year=$1&month=$2&day=$3&news_name=$4&seourl=$4 [L]

RewriteRule ^([^.]+)/page,([0-9]+),([0-9]+),([0-9]+)-(.*).html(/?)+$ index.php?newsid=$4&news_page=$2&cstart=$3&seourl=$5&seocat=$1 [L]
RewriteRule ^([^.]+)/page,([0-9]+),([0-9]+)-(.*).html(/?)+$ index.php?newsid=$3&news_page=$2&seourl=$4&seocat=$1 [L]
RewriteRule ^([^.]+)/print:page,([0-9]+),([0-9]+)-(.*).html(/?)+$ engine/print.php?news_page=$2&newsid=$3&seourl=$4&seocat=$1 [L]
RewriteRule ^([^.]+)/([0-9]+)-(.*).html(/?)+$ index.php?newsid=$2&seourl=$3&seocat=$1 [L]

RewriteRule ^page,([0-9]+),([0-9]+),([0-9]+)-(.*).html(/?)+$ index.php?newsid=$3&news_page=$1&cstart=$2&seourl=$4 [L]
RewriteRule ^page,([0-9]+),([0-9]+)-(.*).html(/?)+$ index.php?newsid=$2&news_page=$1&seourl=$3 [L]
RewriteRule ^print:page,([0-9]+),([0-9]+)-(.*).html(/?)+$ engine/print.php?news_page=$1&newsid=$2&seourl=$3 [L]
RewriteRule ^([0-9]+)-(.*).html(/?)+$ index.php?newsid=$1&seourl=$2 [L]


И меняем все это на:

# Сам пост
RewriteRule ^([^.]+)/(.*).html(/?)+$ index.php?newsid=$2&seourl=$3&seocat=$1 [L]
RewriteRule ^(.*).html(/?)+$ index.php?newsid=$1&seourl=$2 [L]


В конец .htaccess вставляем:

# Сам пост 
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),([0-9]+),(.*).html(/?)+$ index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&cstart=$5&news_name=$6 [L] 
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),(.*).html(/?)+$ index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5 [L] 
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/print:page,([0-9]+),(.*).html(/?)+$ engine/print.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5 [L] 
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*).html(/?)+$ index.php?subaction=showfull&year=$1&month=$2&day=$3&news_name=$4 [L] 
RewriteRule ^([^.]+)/page,([0-9]+),([0-9]+),([0-9]+)-(.*).html(/?)+$ index.php?newsid=$4&news_page=$2&cstart=$3 [L] 
RewriteRule ^([^.]+)/page,([0-9]+),([0-9]+)-(.*).html(/?)+$ index.php?newsid=$3&news_page=$2 [L] 
RewriteRule ^([^.]+)/print:page,([0-9]+),([0-9]+)-(.*).html(/?)+$ engine/print.php?news_page=$2&newsid=$3 [L] 
RewriteRule ^([^.]+)/(.*).html(/?)+$ index.php?newsid=$2 [L] 
RewriteRule ^page,([0-9]+),([0-9]+),([0-9]+)-(.*).html(/?)+$ index.php?newsid=$3&news_page=$1&cstart=$2 [L] 
RewriteRule ^page,([0-9]+),([0-9]+)-(.*).html(/?)+$ index.php?newsid=$2&news_page=$1 [L] 
RewriteRule ^print:page,([0-9]+),([0-9]+)-(.*).html(/?)+$ engine/print.php?news_page=$1&newsid=$2 [L] 
RewriteRule ^(.*).html(/?)+$ index.php?newsid=$1 [L]


Открыть /engine/classes/google.class.php и найти:

$loc = $this->home . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";


И сменить на:

$loc = $this->home . get_url( $row['category'] ) . "/" . $row['alt_name'] . ".html";


Ну вот и все. Теперь мы убрали с Вами ненужный как по мне ID.
Информация
Зарегистрируйтесь чтобы комментировать публикацию.
Авторизация