douyun7718 2015-10-08 14:01
浏览 65

Woocommerce分页404重定向

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:

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染