[resolved] How to redirect old urls because of tag and category bases change (3 posts)

  1. salamandre
    Posted 4 years ago #

    Hi all,

    I have changed the category base to "categorie" (french translation). Now there are a lot of 404 errors. I did the same with the tag base.

    Is it possible to redirect http://www.mywebsite.com/category/hightech/ to http://www.mywebsite.com/categorie/hightech/ with a variable in order to avoid a long list of redirections with all the categories and tags I already have (whatever the tag or category is I want to replace category by categorie etc).

    I hope my explanation is clear enough.

    Thanks in advance.


  2. jrf
    Posted 4 years ago #

    Hi Salamandre,

    Yeah, that's done easily enough. Use variations to the following ruleset:

    Source URL: ^/category/([a-z0-9_-]+)/$
    Match: URL only
    Action: Redirect to URL
    Regex: on
    Target URL: /categorie/{$1}/

    Explanation of the regex:
    ^ = start matching at the very start of the URL-path (the domain is cut off automatically already)
    /category/ = the old name
    () = remember what's between the brackets
    [a-z0-9_-]+ = match a phrase which may use any of the characters between a to z, 0 to 9, _ or -. The plus means 1 or more characters needed.
    If you want, you can tell it to match for instance a minimum of 4 characters and a maximum of 10 by replacing the + with {4,10}.
    / = character match the end slash
    $ = end the URL-path

    The phrase which was caught between the () brackets, is re-used in the target URL by using the $1 (= first - in this case also the only - remembered match).

    So this regex will match for instance:


    But it won't match:

    http://mysite.com/tag/category/hightech/ - Url path doesn't start with /category/
    http://mysite.com/category/hightech - Url path doesn't end with a slash
    http://mysite.com/category/hightech/page1/ - Url path has more info behind the requested match
    http://mysite.com/category/high.tech/ - The . is not within the allowed character range

    Hope this helps!


  3. salamandre
    Posted 4 years ago #

    It is very kind of you Juliette ! It is a lesson and I save it as a PDF !
    Thanks a lot of your help I really appreciate it.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Redirection
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic