: How to redirect 301 within subdomain? 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.
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?
More posts by @Nickens628
1 Comments
Sorted by latest first Latest Oldest Best
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 [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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.