wimexs
Постоялец
- Регистрация
- 21 Авг 2009
- Сообщения
- 161
- Реакции
- 28
killoff, спасибо за помощь хоть решения и не нашёл.
Вылаживаю инструкцию для DLE 10.6 на стандартном шаблоне на других возможно работает нужно пробывать.
Вылаживаю инструкцию для DLE 10.6 на стандартном шаблоне на других возможно работает нужно пробывать.
PHP:
Как убрать ID публикации из URL новости:
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";
}
заменяем на:
####### Новость целиком #################
if ($subaction != '' or $_GET['newsid']) {
if (! $_GET['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 alt_name = '{$_GET['newsid']}'";
if ($subaction == '') $subaction = "showfull";
}
PHP:
2. В файлах /engine/modules/show.full.php ищем:
if( $config['allow_alt_url'] ) {
if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
if( $category_id AND $config['seo_type'] == 2 ) {
$c_url = get_url( $category_id );
$full_link = $config['http_home_url'] . $c_url . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
if ($config['seo_control'] AND ( isset($_GET['seourl']) OR strpos ( $_SERVER['REQUEST_URI'], "?" ) !== false ) ) {
if ($_GET['seourl'] != $row['alt_name'] OR $_GET['seocat'] != $c_url OR strpos ( $_SERVER['REQUEST_URI'], "?" ) !== false OR ($_GET['news_page'] == 1 AND $cstart < 2 AND $view_template != "print") OR ($view_template == "print" AND $news_page > 1) ) {
if ($view_template == "print") {
$re_url = explode ( "engine/print.php", strtolower ( $_SERVER['PHP_SELF'] ) );
$re_url = reset ( $re_url );
} else {
$re_url = explode ( "index.php", strtolower ( $_SERVER['PHP_SELF'] ) );
$re_url = reset ( $re_url );
}
header("HTTP/1.0 301 Moved Permanently");
header("Location: {$re_url}{$c_url}/{$row['id']}-{$row['alt_name']}.html");
die("Redirect");
}
}
$print_link = $config['http_home_url'] . $c_url . "/print:page,1," . $row['id'] . "-" . $row['alt_name'] . ".html";
$short_link = $config['http_home_url'] . $c_url . "/";
$row['alt_name'] = $row['id'] . "-" . $row['alt_name'];
$link_page = $config['http_home_url'] . $c_url . "/" . 'page,' . $news_page . ',';
$news_name = $row['alt_name'];
} else {
$full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
if ($config['seo_control'] AND ( isset($_GET['seourl']) OR strpos ( $_SERVER['REQUEST_URI'], "?" ) !== false ) ) {
if ($_GET['seourl'] != $row['alt_name'] OR $_GET['seocat'] OR $_GET['news_name'] OR strpos ( $_SERVER['REQUEST_URI'], "?" ) !== false OR ($_GET['news_page'] == 1 AND $cstart < 2 AND $view_template != "print") OR ($view_template == "print" AND $news_page > 1) ) {
if ($view_template == "print") {
$re_url = explode ( "engine/print.php", strtolower ( $_SERVER['PHP_SELF'] ) );
$re_url = reset ( $re_url );
} else {
$re_url = explode ( "index.php", strtolower ( $_SERVER['PHP_SELF'] ) );
$re_url = reset ( $re_url );
}
header("HTTP/1.0 301 Moved Permanently");
header("Location: {$re_url}{$row['id']}-{$row['alt_name']}.html");
die("Redirect");
}
}
$print_link = $config['http_home_url'] . "print:page,1," . $row['id'] . "-" . $row['alt_name'] . ".html";
$short_link = $config['http_home_url'];
$row['alt_name'] = $row['id'] . "-" . $row['alt_name'];
$link_page = $config['http_home_url'] . 'page,' . $news_page . ',';
$news_name = $row['alt_name'];
}
} else {
$full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
if ( $config['seo_control'] ) {
if ($_GET['newsid'] OR strpos ( $_SERVER['REQUEST_URI'], "?" ) !== false OR ($_GET['news_page'] == 1 AND $cstart < 2 AND $view_template != "print") OR ($view_template == "print" AND $news_page > 1) ) {
if ($view_template == "print") {
$re_url = explode ( "engine/print.php", strtolower ( $_SERVER['PHP_SELF'] ) );
$re_url = reset ( $re_url );
} else {
$re_url = explode ( "index.php", strtolower ( $_SERVER['PHP_SELF'] ) );
$re_url = reset ( $re_url );
}
header("HTTP/1.0 301 Moved Permanently");
header("Location: {$re_url}".date( 'Y/m/d/', $row['date'] ).$row['alt_name'].".html");
die("Redirect");
}
}
$print_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . "print:page,1," . $row['alt_name'] . ".html";
$short_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] );
$link_page = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . 'page,' . $news_page . ',';
$news_name = $row['alt_name'];
}
} else {
$full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
$print_link = $config['http_home_url'] . "engine/print.php?newsid=" . $row['id'];
$short_link = "";
$link_page = "";
$news_name = "";
}
PHP:
и заменяем на:
if( $config['allow_alt_url'] ) {
if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
if( $category_id AND $config['seo_type'] == 2 ) {
$c_url = get_url( $category_id );
$full_link = $config['http_home_url'] . $c_url . "/" . $row['alt_name'] . ".html";
if ($config['seo_control'] AND ( isset($_GET['seourl']) OR strpos ( $_SERVER['REQUEST_URI'], "?" ) !== false ) ) {
if ($_GET['seourl'] != $row['alt_name'] OR $_GET['seocat'] != $c_url OR strpos ( $_SERVER['REQUEST_URI'], "?" ) !== false OR ($_GET['news_page'] == 1 AND $cstart < 2 AND $view_template != "print") OR ($view_template == "print" AND $news_page > 1) ) {
if ($view_template == "print") {
$re_url = explode ( "engine/print.php", strtolower ( $_SERVER['PHP_SELF'] ) );
$re_url = reset ( $re_url );
} else {
$re_url = explode ( "index.php", strtolower ( $_SERVER['PHP_SELF'] ) );
$re_url = reset ( $re_url );
}
header("HTTP/1.0 301 Moved Permanently");
header("Location: {$re_url}{$c_url}/{$row['alt_name']}.html");
die("Redirect");
}
}
$print_link = $config['http_home_url'] . $c_url . "/print:page,1," . $row['alt_name'] . ".html";
$short_link = $config['http_home_url'] . $c_url . ".html";
$row['alt_name'] = $row['alt_name'];
$link_page = $config['http_home_url'] . $c_url . ".html" . 'page,' . $news_page . ',';
$news_name = $row['alt_name'];
} else {
$full_link = $config['http_home_url'] . $row['alt_name'] . ".html";
if ($config['seo_control'] AND ( isset($_GET['seourl']) OR strpos ( $_SERVER['REQUEST_URI'], "?" ) !== false ) ) {
if ($_GET['seourl'] != $row['alt_name'] OR $_GET['seocat'] OR $_GET['news_name'] OR strpos ( $_SERVER['REQUEST_URI'], "?" ) !== false OR ($_GET['news_page'] == 1 AND $cstart < 2 AND $view_template != "print") OR ($view_template == "print" AND $news_page > 1) ) {
if ($view_template == "print") {
$re_url = explode ( "engine/print.php", strtolower ( $_SERVER['PHP_SELF'] ) );
$re_url = reset ( $re_url );
} else {
$re_url = explode ( "index.php", strtolower ( $_SERVER['PHP_SELF'] ) );
$re_url = reset ( $re_url );
}
header("HTTP/1.0 301 Moved Permanently");
header("Location: {$re_url}{$row['alt_name']}.html");
die("Redirect");
}
}
$print_link = $config['http_home_url'] . "print:page,1," . $row['alt_name'] . ".html";
$short_link = $config['http_home_url'];
$row['alt_name'] = $row['alt_name'];
$link_page = $config['http_home_url'] . 'page,' . $news_page . ',';
$news_name = $row['alt_name'];
}
} else {
$full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
if ( $config['seo_control'] ) {
if ($_GET['newsid'] OR strpos ( $_SERVER['REQUEST_URI'], "?" ) !== false OR ($_GET['news_page'] == 1 AND $cstart < 2 AND $view_template != "print") OR ($view_template == "print" AND $news_page > 1) ) {
if ($view_template == "print") {
$re_url = explode ( "engine/print.php", strtolower ( $_SERVER['PHP_SELF'] ) );
$re_url = reset ( $re_url );
} else {
$re_url = explode ( "index.php", strtolower ( $_SERVER['PHP_SELF'] ) );
$re_url = reset ( $re_url );
}
header("HTTP/1.0 301 Moved Permanently");
header("Location: {$re_url}".date( 'Y/m/d/', $row['date'] ).$row['alt_name'].".html");
die("Redirect");
}
}
$print_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . "print:page,1," . $row['alt_name'] . ".html";
$short_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] );
$link_page = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . 'page,' . $news_page . ',';
$news_name = $row['alt_name'];
}
} else {
$full_link = $config['http_home_url'] . "index.php?newsid=" . $row['alt_name'];
$print_link = $config['http_home_url'] . "engine/print.php?newsid=" . $row['alt_name'];
$short_link = "";
$link_page = "";
$news_name = "";
}
ищем:
if( $config['allow_alt_url'] ) {
if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
if( $related['category'] and $config['seo_type'] == 2 ) {
$rel_full_link = $config['http_home_url'] . get_url( $related['category'] ) . "/" . $related['id'] . "-" . $related['alt_name'] . ".html";
} else {
$rel_full_link = $config['http_home_url'] . $related['id'] . "-" . $related['alt_name'] . ".html";
}
} else {
$rel_full_link = $config['http_home_url'] . date( 'Y/m/d/', $related['date'] ) . $related['alt_name'] . ".html";
}
} else {
$rel_full_link = $config['http_home_url'] . "index.php?newsid=" . $related['id'];
}
и заменяем на:
if( $config['allow_alt_url'] ) {
if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
if( $related['category'] and $config['seo_type'] == 2 ) {
$rel_full_link = $config['http_home_url'] . get_url( $related['category'] ) . "/" . $related['alt_name'] . ".html";
} else {
$rel_full_link = $config['http_home_url'] . $related['alt_name'] . ".html";
}
} else {
$rel_full_link = $config['http_home_url'] . date( 'Y/m/d/', $related['date'] ) . $related['alt_name'] . ".html";
}
} else {
$rel_full_link = $config['http_home_url'] . "index.php?newsid=" . $related['alt_name'];
}
PHP:
3. В файлах /engine/modules/show.short.php ищем:
if( $config['allow_alt_url'] ) {
if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$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'];
}
и заменяем на:
if( $config['allow_alt_url'] ) {
if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$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'];
}
4. В файлах /engine/modules/show.custom.php ищем:
if( $config['allow_alt_url'] ) {
if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$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'];
}
и заменяем на:
if( $config['allow_alt_url'] ) {
if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$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'];
}
PHP:
5. В файлах /engine/modules/topnews.php ищем:
if( $config['allow_alt_url'] ) {
if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$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'];
}
и заменяем на:
if( $config['allow_alt_url'] ) {
if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$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'];
}
6. В файлах /engine/classes/comments.class.php ищем:
if( $config['allow_alt_url'] ) {
if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$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'];
}
и заменяем на:
if( $config['allow_alt_url'] ) {
if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$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'];
}
7. Открываем файл /.htaccess и ищем:
# Сам пост
и то что под этой строчкой (12 строк кода) удаляем и заменяем на:
# Сам пост
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]+),(.*).html$ index.php?newsid=$4&news_page=$2&cstart=$3&seocat=$1 [L]
RewriteRule ^([^.]+)/page,([0-9]+),(.*).html$ index.php?newsid=$3&news_page=$2&seocat=$1 [L]
RewriteRule ^([^.]+)/print:page,([0-9]+),(.*).html$ engine/print.php?news_page=$2&newsid=$3&seocat=$1 [L]
RewriteRule ^([^.]+)/(.*).html$ index.php?newsid=$2&seocat=$1 [L]
RewriteRule ^page,([0-9]+),([0-9]+),(.*).html$ index.php?newsid=$3&news_page=$1&cstart=$2 [L]
RewriteRule ^page,([0-9]+),(.*).html$ index.php?newsid=$2&news_page=$1 [L]
RewriteRule ^print:page,([0-9]+),(.*).html$ engine/print.php?news_page=$1&newsid=$2 [L]
RewriteRule ^(.*).html$ index.php?newsid=$1 [L]
Последнее редактирование модератором: