0

I want to redirect the main domain to a subdirectory but keep working in the backend of the main domain. I wish to edit my .htaccess file.

So:

example.com

SHOULD BE 301 REDIRECTED TO

example.com/subdirectory

but keep my access in example.com/wp-admin and continue working in the backend without being redirected

how to fix this?

1 Answer 1

0

I'm assuming that you are willing to do this for maintenance mode, 301 is for permanent redirect. You can add this snippet in functions.php to enable redirection of the entire wordpress site to another site.

add_action( 'template_redirect', 'wp_maintance_mode' );

function wp_maintance_mode() {
        wp_redirect( "http://new_url" ); 

// or if the folder is outside wordpress and lies under same url
wp_redirect( home_url('/folder_name')  );
        exit;
} 

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.