Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have multi-site wordpress, I want to redirect the main site to one of the sub-site but redirection in .htacecss gives error. Is there any way to redirect a main site to its sub-site. That looks not possible but I am not a wordpress expert so just verifying.

The redirect should be like

redirect 301

Or if there is any other way to do that?

share|improve this question

1 Answer 1

up vote 8 down vote accepted

You can use the parse_request action to accomplish this. Simply enable this plugin on your primary blog. Place the following code in a .php file and upload it to your plugins directory.

Plugin Name: Redirect Main Site To Sub-Site
Description: Redirect 'main-site' to 'main-site/sub-site/'
Version: 0.1
Author: WPSE
Author URI:
License: GPL2

add_action('parse_request', 'redirect_to_sub_site');
function redirect_to_sub_site(){
    global $wp;

    #Sniff requests for a specific slug
    if('main-site' === $wp->request){

        #The URL to redirect TO
        $url = '';

        #Let WordPress handle the redirect - the second parameter is obviously the status
        wp_redirect($url, 301);

        #It's important to exit, otherwise wp_redirect won't work properly

Let me know if you have any questions.

share|improve this answer
+1 And here's it again as nice two liner ;) –  kaiser Sep 27 '12 at 0:49
Worked perfect Thanks!!! –  Toqeer Sep 27 '12 at 1:33
@Toqeer You should Award the bounty. Won't get it back anway. ;) –  kaiser Sep 27 '12 at 19:50
Just awarded, I thought it will be automatically awarded :) –  Toqeer Sep 28 '12 at 6:16
I tried now with the latest WordPress version but it is not working. Do you have any idea? –  User Jul 29 at 9:57

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.