I have 2 campaigns at

  • competition.example.com/option_1
  • competition.example.com/option_2

option_1 and optino_2 are in separate folders which are in root folder. Each file and root has its own .htaccess.

Content of:
.htaccess of option_1
.htaccess of root

How and where (which .htaccess) can I 301 redirect from competition.example.com/option_1 to competition.example.com/option_2?

  • Where is the competition subdomain located on the filesystem? ...In a subdirectory called competition, off the document root? Do you have other .htaccess files already on your system?
    – MrWhite
    May 27, 2016 at 14:51
  • In document root I have the 2 files (option_1 and option_2)
    – Luxqs
    May 30, 2016 at 7:58
  • "option_1 and optino_2 are in separate filies which are in root file. Each file and root has its own .htaccess." - Do you mean, "option_1 and option_2 are separate folders in the root. Each folder and root has its own .htaccess file"?
    – MrWhite
    Jun 7, 2016 at 14:34
  • Yes, 2 x folder in the root. Each folder and rood has its own .htaccess.
    – Luxqs
    Jun 7, 2016 at 14:39

1 Answer 1


In the .htaccess file where competition.example.com points to on the filesystem, you can use a mod_alias Redirect:

Redirect 301 /option_1 /option_2

This assumes you don't have any existing mod_rewrite (ie. RewriteRule) redirects that might conflict.

Note that .htaccess files inherit along the filesystem path (regardless of whether you are using subdomains or not). So if the competition subdomain actually points to a /competition subdirectory off the main domain's document root, then the .htaccess file in the parent directory (the main domain's document root) will be processed second.

However, by default, mod_rewrite directives are not inherited (mod_rewrite is different to other modules in this respect). So directives in the child (subdirectory) .htaccess file will completely override the parent.

UPDATE: Since you are using mod_rewrite throughout your root .htaccess file you should change the above (mod_alias) Redirect to use mod_rewrite as well. mod_rewrite will execute before mod_alias, regardless of the order of directives in .htaccess, so it's quite possible there is a conflict.

At the very top of your root .htaccess file (which I assume is the root of subdomain), try the following:

RewriteRule ^option_1(.*)$ /option_2$1 [R=302,L]

This assumes you don't have files that start "option_1".

Change the 302 (temporary) redirect to 301 (permanent) redirect when you are sure it's working OK. 301 redirects are cached by the browser, so can make testing problematic. For this reason you need to make sure your browser cache is emptied before testing.

  • just to be sure. Its should not be like: Redirect 301 /option_1 competition.example.com/option_2 but just like Redirect 301 /option_1 /option_2?
    – Luxqs
    May 30, 2016 at 7:59
  • I tried both methods and I did it in root .htaccess and also in .htaccess which is in folder option_1. Non is working.
    – Luxqs
    May 30, 2016 at 8:11
  • Redirect 301 /option_1 /option_2 is OK on Apache 2.2.6+. Note that if you specify the domain you must specify a complete absolute URL eg. http://competition.example.com/option_2. What does "not working" mean - does it do anything? Note that 301 redirects are cached by the browser, so if you have previously tested other (erroneous) redirects then you will need to repeatedly clear your browser cache. So, these are "folders", not "files" as you stated in your comment above? Is .htaccess enabled on your server? Do you have other .htaccess files (anywhere)?
    – MrWhite
    May 30, 2016 at 14:04
  • Note that example.com also applies if it is on the same filesystem.
    – MrWhite
    May 30, 2016 at 14:04
  • Im back. Im sorry, its a folder. I have .htaccess in folders: option_1, option_2 and also in the root. By the "its not working" I mean, I dont see redirection even I use different browser.
    – Luxqs
    Jun 7, 2016 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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