SEO friendly pagination

Post your suggestions for the script here.

SEO friendly pagination

Postby webbber » Thu Sep 11, 2008 5:34 pm

I have block urls with this: ? via robots.txt , so my news pagination cant be indexed.
Is there any way so change the pagination URLS to page-1.html instead of news/index.php?skip=2 and so on...

is there?
webbber
 
Posts: 155
Joined: Thu May 15, 2008 1:13 am

Postby FI-DD » Fri Sep 12, 2008 2:16 pm

Try this:

1. Go to Options -> User Friendly Urls and put this into the first box:
Code: Select all
# pagination
RewriteRule ^page-([0-9]+)$ ?skip=$1 [QSA,L]


Then click "Save urls.ini" and click "Create .htaccess"


2. Open inc/show.news.php and replace every

Code: Select all
'.$PHP_SELF.'?skip=


with

Code: Select all
http://www.yourdomain.com/page-
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby webbber » Fri Sep 12, 2008 5:37 pm

working gr8, Love ya man!!!

I had tried that out but failed. So thanks a lot, I have been waiting for this!

I get urls like:
Code: Select all
site.com/news/page-2


to get .html after page number change to:
Code: Select all
# pagination
RewriteRule ^page-([0-9]+).html$ ?skip=$1 [QSA,L]


and in inc/show.news.php:
Code: Select all
/----------------------------------
// Previous link
//----------------------------------
if ($skip){
   $prev_next_msg = preg_replace('/\[prev-link\](.*?)\[\/prev-link\]/si', '<a href="'.$PHP_SELF.'noticias/page-'.($skip - $number).'.html">\\1</a>', $prev_next_msg);
   $prev_next_msg = preg_replace('/\[first-link\](.*?)\[\/first-link\]/si', '<a href="'.$PHP_SELF.'noticias/page-0.html">\\1</a>', $prev_next_msg);
} else {
   $prev_next_msg = preg_replace('/\[prev-link\](.*?)\[\/prev-link\]/si', '', $prev_next_msg);
   $prev_next_msg = preg_replace('/\[first-link\](.*?)\[\/first-link\]/si', '', $prev_next_msg);
   $no_prev = true;
}

and so on....

got me?

enjoy!
webbber
 
Posts: 155
Joined: Thu May 15, 2008 1:13 am

Postby webbber » Fri Sep 12, 2008 9:06 pm

Something else,
When Im browsing into a category, eg:
site.com/category/sports/ and im paginating
when I click on the NEXT articles page, I get the same url like im in the main news page (sitem.com/news/page-1.html)
But, If we?re browsing a category, we should have urls like this:
site.com/category/sports/page-2.html
right?
How can we get this?
webbber
 
Posts: 155
Joined: Thu May 15, 2008 1:13 am

Postby FI-DD » Thu Sep 18, 2008 7:47 pm

New approach:

1. Go to Options -> User Friendly Urls and put this into the first box:
Code: Select all
# pagination
RewriteRule ^page-([0-9]+)$ ?skip=$1 [QSA,L]
RewriteRule ^category/([0-9a-z]+)/page-([0-9]+)$ ?category=$1&skip=$2 [QSA,L]
RewriteRule ^([0-9]+)/([0-9]+)/page-([0-9]+)$ ?year=$1&month=$2&skip=$3 [QSA,L]



Then click "Save urls.ini" and click "Create .htaccess"


2. Open inc/show.news.php and find this:
Code: Select all
$PHP_SELF      = @preg_replace($skip.'$', '', $_SERVER['REQUEST_URI']);
$prev_next_msg = $template_prev_next;


add below:
Code: Select all
$my_page = "http://www.domain.com/news/"; //Change to your path
if($category){
   $my_page .= 'category/'.category_get_link($category).'/';
}
if($year and $month){
   $my_page .= $year.'/'.$month.'/';
}
$my_page .= "page-";


3. In inc/show.news.php change every:
Code: Select all
.$PHP_SELF.'?skip='.


to this:
Code: Select all
.$my_page.
Last edited by FI-DD on Thu Sep 25, 2008 5:18 pm, edited 1 time in total.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby webbber » Fri Sep 19, 2008 10:26 pm

ok, let me try that.
I have also activated the ARCHIVE function, so that it can shows articles that have been sent per month.
For ex: At August, I get this at the title: News > 2008 > 08, But I have the same issue with pagination.
At this month I have more than 200 articles, and when I click on the NEXT PAGE link I get the same URl just like before:
site.com/news/page-2.html and it should be:
site.com/news/2008/08/page-2.html

I think that the inc/show_news.php should have some kind of condition depending on URL your surfing.
Like, if you watching the categories page, or the news main page, or archives pages. Just for pagination.

Hope you understand guys,
regards
webbber
 
Posts: 155
Joined: Thu May 15, 2008 1:13 am

Postby FI-DD » Thu Sep 25, 2008 5:18 pm

I edited the code above. Please try again.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby flyboy17 » Sun Oct 19, 2008 12:10 am

this one is nice. But can you also change/reverse the order of the url's?

for example
0.html would contain the oldest news (newsitem 1,2,3..7)
1.html contain newsitems 8,9...14.
...
x.html would contain the most recent newsitems.


Difference? In this case the content of the html pages would always contain the same newsitems.

Thanks :)
flyboy17
 
Posts: 63
Joined: Wed Feb 21, 2007 4:32 pm

Postby Ned Flanders » Tue Nov 17, 2009 3:07 pm

FI-DD wrote:I edited the code above. Please try again.


It almost worked. URL's are fine now and it works in the main news section (domain.com/).

But what doesn't work is when you're inside a category. The "category/name_cateogry/" part is now included in the pagination link, but it doesn't go anywhere:

http://www.website.com/category/category_name/page-6 (page cannot be displayed)

When I manually change it to
http://www.website.com/category/categor ... kip=NUMBER

It works again. So somehow the categories can't handle 'page-' .

Please help me.
User avatar
Ned Flanders
 
Posts: 55
Joined: Mon May 11, 2009 10:28 pm
Location: Holy Kingdom

Postby Ned Flanders » Tue Nov 17, 2009 3:34 pm

I have found the problem.
I either just can't handle category url names consisting of more than one word or it just can't handle a hyphen ('-').
User avatar
Ned Flanders
 
Posts: 55
Joined: Mon May 11, 2009 10:28 pm
Location: Holy Kingdom


Return to Suggestions



Who is online

Users browsing this forum: No registered users and 0 guests

cron