Regular Expression for redirecting category pagination (4 posts)

  1. foggyphils
    Posted 4 years ago #

    I'm trying to consolidate categories on my wp website and need help with 2 similar but different situations. I'm using the redirection plugin.
    (Also I'm already using Yoast's Seo Plugin which already gets rid of the category sub folder. mysite.com/category/dogs/ -> mysite.com/dogs/ ....the plugin also adds the trailing slash..not sure if this is relevant, but want to provide as much info as possible)

    1. I'm changing the slug of a category that I will continue to use from:
    /cute-dogs/ -> /cute-and-fluffy-dogs/
    I did a plain old redirect, but that doesn't redirect the pages?- ie. /cute-dogs/page/2/ -> /cute-and-fluffy-dogs/page/2/
    So is there a regular expression I can use in this case?

    2. I'm getting rid of /fluffy-dogs/ and redirecting to /cute-and-fluffy-dogs/ (the category above). Again, I did a plain old redirect but it doesn't redirect the pages..ie:
    /fluffy-dogs/page/2/ -> /cute-and-fluffy-dogs/page/2/

    The same regular expression may work for both? But I'm not sure. Any help is greatly appreciated!

  2. vtxyzzy
    Posted 4 years ago #

    Not sure why you would need a regex. Wouldn't a str_replace work?

    $new_url = str_replace(
       array('/cute-dogs/page/', '/fluffy-dogs/page/'),
       array('/cute-and-fluffy-dogs/page/', '/cute-and-fluffy-dogs/page/',
  3. foggyphils
    Posted 4 years ago #

    I'm sorry I think we may be talking about 2 different things?

    I've already changed the urls, but I need to redirect the old urls that have inbound links and are indexed by search engines.

  4. adpawl
    Posted 4 years ago #


Topic Closed

This topic has been closed to new replies.

About this Topic