Не нравятся результаты поиска? Попробуйте другой поиск!
dle-faq.ru FAQ (все вопросы) Общие вопросы по PHP Как оставить только ID новости в адресе публикации?

Как оставить только ID новости в адресе публикации?


     15.07.2014    Общие вопросы по PHP, Хаки    1698

вопрос
Здравствуйте, помогите пожалуйста изменить адрес новостей с site.ru/1875-imya-novosti.html на site.ru/1875.html. Заранее спасибо.

Ответил: D0Gmatist


Это мануал (как то делал, был заказ) по смене местами id alt_name = и = alt_name id
Исходя из этого мануала можно понять что и где править
#####################
//.htaccess
#####################
//*********************

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 ^([^.]+)/page,([0-9]+),([0-9]+),(.*)-([0-9]+).html$ index.php?seourl=$4&news_page=$2&cstart=$3&newsid=$5&seocat=$1 [L]
RewriteRule ^([^.]+)/page,([0-9]+),(.*)-([0-9]+).html$ index.php?seourl=$3&news_page=$2&newsid=$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?seourl=$2&newsid=$3&seocat=$1 [L]

RewriteRule ^page,([0-9]+),([0-9]+),(.*)-([0-9]+).html$ index.php?seourl=$3&news_page=$1&cstart=$2&newsid=$4 [L]
RewriteRule ^page,([0-9]+),(.*)-([0-9]+).html$ index.php?seourl=$2&news_page=$1&newsid=$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?seourl=$1&newsid=$2 [L]

//*********************




#####################
//\engine\modules\show.short.php
#####################
//********************* строка 357
                    $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
//<====>
                    $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['alt_name'] . "-" . $row['id'] . ".html";
//********************* строка 361
                    $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
//<====>
                    $full_link = $config['http_home_url'] . $row['alt_name'] . "-" . $row['id'] . ".html";
//*********************




#####################
//\engine\modules\topnews.php
#####################
//********************* строка 82
                    $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
//<====>
                    $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['alt_name'] . "-" . $row['id'] . ".html";
//********************* строка 86
                    $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
//<====>
                    $full_link = $config['http_home_url'] . $row['alt_name'] . "-" . $row['id'] . ".html";
//*********************




#####################
//\engine\modules\addcomments.php
#####################
//********************* строка 428
                        $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
//<====>
                        $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['alt_name'] . "-" . $row['id'] . ".html";
//********************* строка 432
                        $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
//<====>
                        $full_link = $config['http_home_url'] . $row['alt_name'] . "-" . $row['id'] . ".html";
//*********************




#####################
//\engine\modules\show.full.php
#####################
//********************* строка 161
                    $full_link = $config['http_home_url'] . $c_url . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
//<====>
                    $full_link = $config['http_home_url'] . $c_url . "/" . $row['alt_name'] . "-" . $row['id'] . ".html";
//********************* строка 195
                    $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
//<====>
                    $full_link = $config['http_home_url'] . $row['alt_name'] . "-" . $row['id'] . ".html";
//********************* строка 876
                                $rel_full_link = $config['http_home_url'] . get_url( $related['category'] ) . "/" . $related['id'] . "-" . $related['alt_name'] . ".html";
//<====>
                                $rel_full_link = $config['http_home_url'] . get_url( $related['category'] ) . "/" . $related['alt_name'] . "-" . $related['id'] . ".html";
//********************* строка 880
                                $rel_full_link = $config['http_home_url'] . $related['id'] . "-" . $related['alt_name'] . ".html";
//<====>
                                $rel_full_link = $config['http_home_url'] . $related['alt_name'] . "-" . $related['id'] . ".html";
//*********************




#####################
//\engine\modules\show.custom.php
#####################
//********************* строка 293
                $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
//<====>
                $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['alt_name'] . "-" . $row['id'] . ".html";
//********************* строка 297
                $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
//<====>
                $full_link = $config['http_home_url'] . $row['alt_name'] . "-" . $row['id'] . ".html";
//*********************




#####################
//\engine\inc\editnews.php
#####################
//********************* строка 199
                    $full_link = $config['http_home_url'] . get_url( intval( $row['category'] ) ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
//<====>
                    $full_link = $config['http_home_url'] . get_url( intval( $row['category'] ) ) . "/" . $row['alt_name'] . "-" . $row['id'] . ".html";
//********************* строка 203
                    $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
//<====>
                    $full_link = $config['http_home_url'] . $row['alt_name'] . "-" . $row['id'] . ".html";
//*********************




#####################
//\engine\inc\complaint.php
#####################
//********************* строка 295
                $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['post_id'] . "-" . $row['alt_name'] . ".html";
//<====>
                $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['alt_name'] . "-" . $row['post_id'] . ".html";
//********************* строка 299
                $full_link = $config['http_home_url'] . $row['post_id'] . "-" . $row['alt_name'] . ".html";
//<====>
                $full_link = $config['http_home_url'] . $row['alt_name'] . "-" . $row['post_id'] . ".html";
//********************* строка 463
                $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['post_id'] . "-" . $row['alt_name'] . ".html";
//<====>
                $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['alt_name'] . "-" . $row['post_id'] . ".html";
//********************* строка 467
                $full_link = $config['http_home_url'] . $row['post_id'] . "-" . $row['alt_name'] . ".html";
//<====>
                $full_link = $config['http_home_url'] . $row['alt_name'] . "-" . $row['post_id'] . ".html";
//*********************




#####################
//\engine\inc\comments.php
#####################
//********************* строка 124
                    $full_link = $config['http_home_url'] . get_url( intval( $row['category'] ) ) . "/" . $row['post_id'] . "-" . $row['alt_name'] . ".html";
//<====>
                    $full_link = $config['http_home_url'] . get_url( intval( $row['category'] ) ) . "/" . $row['alt_name'] . "-" . $row['post_id'] . ".html";
//********************* строка 128
                    $full_link = $config['http_home_url'] . $row['post_id'] . "-" . $row['alt_name'] . ".html";
//<====>
                    $full_link = $config['http_home_url'] . $row['alt_name'] . "-" . $row['post_id'] . ".html";
//*********************




#####################
//\engine\inc\cmoderation.php
#####################
//********************* строка 103
                $full_link = $config['http_home_url'] . get_url( intval( $row['category'] ) ) . "/" . $row['post_id'] . "-" . $row['alt_name'] . ".html";
//<====>
                $full_link = $config['http_home_url'] . get_url( intval( $row['category'] ) ) . "/" . $row['alt_name'] . "-" . $row['post_id'] . ".html";
//********************* строка 107
                $full_link = $config['http_home_url'] . $row['post_id'] . "-" . $row['alt_name'] . ".html";
//<====>
                $full_link = $config['http_home_url'] . $row['alt_name'] . "-" . $row['post_id'] . ".html";
//*********************




#####################
//\engine\ajax\search.php
#####################
//********************* строка 115
                    $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
//<====>
                    $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['alt_name'] . "-" . $row['id'] . ".html";
//********************* строка 119
                    $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
//<====>
                    $full_link = $config['http_home_url'] . $row['alt_name'] . "-" . $row['id'] . ".html";
//*********************




#####################
//\engine\ajax\find_relates.php
#####################
//********************* строка 123
                $full_link = $config['http_home_url'] . get_url( $related['category'] ) . "/" . $related['id'] . "-" . $related['alt_name'] . ".html";
//<====>
                $full_link = $config['http_home_url'] . get_url( $related['category'] ) . "/" . $related['alt_name'] . "-" . $related['id'] . ".html";
//********************* строка 127
                $full_link = $config['http_home_url'] . $related['id'] . "-" . $related['alt_name'] . ".html";
//<====>
                $full_link = $config['http_home_url'] . $related['alt_name'] . "-" . $related['id'] . ".html";
//*********************




#####################
//\engine\classes\comments.class.php
#####################
//********************* строка 230
                            $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['post_id'] . "-" . $row['alt_name'] . ".html";
//<====>
                            $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['alt_name'] . "-" . $row['post_id'] . ".html";
//********************* строка 234
                            $full_link = $config['http_home_url'] . $row['post_id'] . "-" . $row['alt_name'] . ".html";
//<====>
                            $full_link = $config['http_home_url'] . $row['alt_name'] . "-" . $row['post_id'] . ".html";
//*********************

Комментарии пользователей (6)

JacobClyne
10

28 | 8

JacobClyne - 15 июля 2014 20:44 - Юзер

Ответ к комментарию
Это я знаю, вы вопрос читали вообще? Мне нужно так http://site.ru/id.html без имени новости.

Sander
1125

1636 | 1202

Sander - 16 июля 2014 01:28 - Эксперт

Думаю если вы подкинете ему парочку бакинских - он согласится переделать инструкцию так как нужно именно вам.

SanDev.pro - мой блог.

ICQ: 404-037-556
Skype: Sander8804

D0Gmatist
225

794 | 281

D0Gmatist - 16 июля 2014 02:18 - Местный

Даже не буду браться... )))

Каждый программист знает - в правильном софте все должно быть прекрасно:
и пользовательский интерфейс, и программные решения, и гениальные ошибки!
Болтовня ничего не стоит. Покажите мне код.

JacobClyne
10

28 | 8

JacobClyne - 16 июля 2014 02:48 - Юзер

Я все уже сделал. Еще раз спасибо :)

rullan
3

rullan - 6 июля 2016 22:50 - Юзер

Можно узнать как Вы сделали переадресацию на http://site.ru/id.html без имени новости.?

dgt_arts
56 | 11

dgt_arts - 15 июля 2014 20:47 - Юзер

В настройки зайди

Тип ЧПУ:
Тип 1 - ссылки на полную новость будут иметь вид http://site.ru/id-имя новости.html

Тип 2 - ссылки на полную новость будут иметь вид http://site.ru/категория/подкатегория/id-имя новости.html

Тип 3 - ссылки на полную новость будут иметь вид http://site.ru/2008/04/02/имя новости.html, внимание данный тип несет повышенную

Чтобы комментировать - войдите или зарегистрируйтесь на сайте

Похожие вопросы