Question: How do I redirect this page URL, `http://localhost/wordpress_rnd/?page_id=2`, to the home URL, `http://localhost/wordpress_rnd/`, without using any plugins?

Answer: 
```
add_action( 'init', function() {
    if ( 0 === stripos( $_SERVER['REQUEST_URI'], '/page_id=2' ) ) {

       wp_redirect( home_url(), 301 );
       exit;

    }
}

```

Put this code in a mu-plugin or in your theme's functions.php file
Locate page.php (assuming you've created it already). After this line `<?php get_header(); ?>` add the following code:

```
<?php if(is_page('2')) {
    wp_redirect( home_url(), '302' ); 
} ?>

```

In the code above, `is_page('2')` is actually the ID of your page as you've specified in your example.