Pagination with permalink (SEO friendly)

2 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: March 5, 2015   (RSS)

By Jesus - February 25, 2015

Hi, I was browsing the forums and I found this thread (http://www.interactivetools.com/forum/forum-posts.php?postNum=2230451#post2230451) but it seems it never was completed before.

Is it possible to have SEO friendly urls for pagination? if so, will someone share with me how can we setup this. I was thinking probably to have the links like: 

www.domain.com/section-name/page-2

www.domain.com/section-name/page-3

and so on...

Thanks in advance and sorry for pointing out to an old archived thread.

Jesus

By Daryl - March 5, 2015

Hi Jesus,

You can use .htaccess to rewrite the pagination URL.

For example:
We will rewrite www.domain.com/section-name/?page=2 to www.domain.com/section-name/page-2

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule   ^section-name/page-([0-9]+)/?$   section-name/?page=$1 [QSA]

And then on your pagination links, replace the default ?page=1, ?page=2 and so on with /page-1, /page-2 and so on.

How it works:
The "([0-9]+)" part of the htaccess code, which will contains the page number, is passed over to "$1"
This means that your $_REQUEST['page'] will have a value equals to whatever number is in the "([0-9]+)".

If you're using permalink plugin, the rewrite code should come before the permalink htaccess dispatcher code.

Cheers,

Daryl Maximo
PHP Programmer - interactivetools.com