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: 
The correct way to do this is using the [`template_redirect`](https://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect) hook by adding a function to your `functions.php`:

```
function redirect_to_home() {
  if(!is_admin() && is_page('2')) {
    wp_redirect(home_url());
    exit();
  }
}
add_action('template_redirect', 'redirect_to_home');

```
[WP\_REDIRECT](http://codex.wordpress.org/Function_Reference/wp_redirect) is the function that you need to use for redirecting in wordpress. It can be used like :

```
wp_redirect( $location, $status );
exit;
//$location is required parameter. It is used to give the target url to which page will get redirected.
//$status is optional. It is used to set status code. Default is 302

```

You can use this function to redirect users from one page to other. It should be placed in either functions.php or the template file which is being used to display the current page. Now to use it in your situation, simple place the following code at the bottom of your functions.php file

```
$redirectFromPageID = 2;  //Redirect from Page having ID of 2
$redirectTo = home_url(); //Redirect to Home URL

if( is_page( $redirectFromPageID ) ){
    wp_redirect( $redirectTo  );
    exit;
}

```