Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

If I change a folder name in server ant thus the URL will be changed, could I perform 301 redirection or this is only for the case that the web page has been transferred to another folder?

share|improve this question

2 Answers 2

Entire folders can be redirected, just like files can. You can add a line like this to .htaccess:

Redirect permanent /OLD

Which will cause every file in the directory to be 301 redirected:

  • ->
  • ->
  • ->

This is documented in Apache's mod_alias redirect documentation

share|improve this answer
So even in the case that it is for dynamic web pages (phpbb forum), according to you a single code line in the .htaccess folder is enough for such a redirection? – hyweb Oct 9 '13 at 10:48
Yes, redirects are very simple to implement. – Stephen Ostermiller Oct 9 '13 at 10:50
Please note that I have seen here: and the code that arises for such a case is: //301 Redirect Entire Directory RedirectMatch 301*)$1 So it is not exactly as specified by you – hyweb Oct 9 '13 at 11:01
RedirectMatch works as well, but it is not needed. RedirectMatch directives take more processing since they rely on regular expressions. Plain Redirect directives should be preferred when they work. The redirect documentation that I linked shows a very similar example with a folder redirected to a different subdomain and foo.txt being redirected inside it. – Stephen Ostermiller Oct 9 '13 at 11:09
I have seen in the server that the .htaccess exists in www as well as in public_html... would it be the same either the one or the other to be changed? Moreover, could you please let me know where this code shall be added or it is not necessary to be added in specific place – hyweb Oct 9 '13 at 11:16

If the URL has changed, you'll need a redirect. If a certain page was in before and is now in, you'll need to redirect it. A 301 redirect is for the case that a page has been transferred to another folder, but for all practical purposes, changing the folders name is the same as putting the files in a different folder.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.