Woocommerce pagination 404 redirection

I have a problem with woocommerce pagination but i can’t described, you can reproduce the error in the site. go to this link and scroll till pagination, then try to click one of the pagination’s links. You will see that it redirects to a 404 page and also add page/XX/ to the end of the url.

As an example the url in the number 2 is:

Read More

http://alibabaonline.com.co/categoria-producto/juguetes/anillos-estimulantes/page/2/medellin

but when you click that number the url redirects to 404 page and also adds this new url:

http://alibabaonline.com.co/categoria-producto/juguetes/anillos-estimulantes/page/2/page/2/medellin/page/2/

So, as you can see I also add and extra ‘argument’ to the url, the name of a city, in this case is medellin, in order to do this I rewrite url’s, and this is what I’m doing:

 function custom_rewrite_basic() {
    add_rewrite_rule('^tienda/page/?([0-9]{1,})/([^/]+)/?$','index.php?post_type=product&paged=$matches[1]&ciudad=$matches[2]', 'top');
    add_rewrite_rule('^blog/page/?([0-9]{1,})/([^/]+)/?$','index.php?category_name=blog&paged=$matches[1]&ciudad=$matches[2]', 'top');//Paginación
    add_rewrite_rule('^tienda/(.+?)/([^/]+)/([^/]+)/?$','index.php?page=tienda&product_cat=$matches[1]&product=$matches[2]&ciudad=$matches[3]', 'top'); //Para detalle producto
    add_rewrite_rule('^categoria-producto/(.+?)/page/?([0-9]{1,})/([^/]+)/?$','index.php?product_cat=$matches[1]&paged=$matches[2]&ciudad=$matches[3]', 'top');//Paginación
    add_rewrite_rule('^categoria-producto/(.+?)/([^/]+)/?$','index.php?product_cat=$matches[1]&ciudad=$matches[2]', 'top'); //Para cpt productCat/medellin

    add_rewrite_rule('([^/]+)/?$','index.php?ciudad=$matches[1]', 'top'); // Para index/ciudad
    add_rewrite_rule('([^/]*)?/([^/]+)/?$','index.php?pagename=$matches[1]&ciudad=$matches[2]', 'top'); // Para pagina/ciudad

    add_rewrite_rule('^tiendas/([^/]+)/?$','index.php?post_type=tiendas&ciudad=$matches[1]', 'top'); //Para cpt tiendas/medellin
    add_rewrite_rule('^catalogo/([^/]+)/?$','index.php?post_type=catalogo&ciudad=$matches[1]', 'top'); //Para cpt catalogo/medellin
    add_rewrite_rule('^catalogo/([^/]+)/([^/]+)/?$','index.php?post_type=catalogo&catalogo=$matches[1]&ciudad=$matches[2]', 'top'); //Para cpt single/catalogo
    add_rewrite_rule('^cat_marcas/([^/]+)/([^/]+)/?$','index.php?cat_marcas=$matches[1]&ciudad=$matches[2]', 'top'); //Para cpt marcas/medellin

    add_rewrite_rule('^search/(.+)/([^/]+)/?$','index.php?s=$matches[1]&ciudad=$matches[2]', 'top'); //Para buscador

    add_rewrite_rule('^blog/([^/]+)/?$','index.php?category_name=blog&ciudad=$matches[1]', 'top'); //Para la categoría blog/ciudad
    add_rewrite_rule('^blog/([^/]+)/([^/]+)/?$','index.php?category_name=blog&category_name=$matches[1]&ciudad=$matches[2]', 'top'); // Widget categorias
    add_rewrite_rule('^blog/page/?([0-9]{1,})/([^/]+)/?$','index.php?category_name=blog&paged=$matches[1]&ciudad=$matches[2]', 'top'); //Para la paginacion blog/ciudad
    add_rewrite_rule('([^/]+)?/([^/]+)/?$','index.php?name=$matches[1]&ciudad=$matches[2]', 'top'); //Para el nombreDeLaEntrada/ciudad

}
add_action('init', 'custom_rewrite_basic');

The rewrite rule that I’m using to do the pagination is:

add_rewrite_rule('^categoria-producto/(.+?)/page/?([0-9]{1,})/([^/]+)/?$','index.php?product_cat=$matches[1]&paged=$matches[2]&ciudad=$matches[3]', 'top');//Paginación

One more think is that in my local machine, works well.

Thank you in advance

Related posts