user1729506
user1729506

Reputation: 975

301 Redirect directory and any possible files therein to new directory

I am trying to redirect an old directory, all possibly sub-directories, and all possible files all to one new directory.

Redirect anything such as:

and so on all should redirect to .com/new

I've tried several .htaccess generators and tutorials, and I get a very mixed baskets of results.

For example, the most common problem I get is that .com/old/older/index.php will redirect to .com/new/older/index.php instead of just .com/new.

Upvotes: 2

Views: 49

Answers (1)

anubhava
anubhava

Reputation: 785256

You can use this simple 301 rule in your site root .htaccess:

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

Or else use this rule in /old/.htaccess file:

RedirectMatch 301 ^ /new

Upvotes: 2

Related Questions