Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just did a 301 and the domain and some pages which have a mirror file path are fine.

But I have one directory which is not going to be part of the new site and I don't know how to redirect the old files that were there.

I need something like this: oldDomain/oldDir/file.php

and I need to make it redirect to


Is that possible? What is the 301 redirect rule for that?


I just added this rule as suggested by @Itai and it didn't work

redirectMatch permanent ^/outdoors/trees/tanoak.php$ http://www.comehike.com/outdoors/trees/129/Tanoak

any idea why?

share|improve this question

migrated from webapps.stackexchange.com Mar 3 '11 at 15:55

This question came from our site for power users of web applications.

Are you missing a file at the end of your rule? If that is a directory, use a / at the end. If not, try it as your first rule (in case others have precedence). If it still does not work, check your Apache config to make that .htaccess use is enabled, your .htaccess is readable (permissions) by Apache and it is either in the right path or in its parent path. – Itai Mar 7 '11 at 1:01

For each page, you need a redirect like the following in your .htaccess:

redirectMatch permanent ^/oldDir/file.php$ http://www.newdomain.com/differentDir/file.php

Notice you do not use the 'oldDomain', this is implied because the .htaccess you modify has to be on the old domain's server.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.