WordPress > htaccess > redirect directory and all its sub-directories to one directory

Is it possible to redirect a directory and all its sub-directories to another location with a single redirect rule within wordpress´ htaccess file?

e.g.

Read More
http://example.com/old
http://example.com/old/foo
http://example.com/old/foo/bar

move them all to

http://example.com/new

when I try this

RedirectMatch 301 ^/old/(.*)$ /new/

while pointing to

http://example.com/old/foo/bar 

it ends up with

http://example.com/new/bar

Related posts

Leave a Reply

1 comment

  1. You can put this rule in your htaccess (before WordPress’ main rule, after RewriteEngine On line)

    RewriteRule ^old(/.*)?$ /new [R=301,L]
    

    Note: you may have to clear your browser cache since your old rule is stored into it