Andrew
Andrew

Reputation: 1575

Wordpress how to redirect url

I want to redirect user to home page when he just enters on the website. For example typing www.website.com need redirect to www.website.com/home

I trued to redirect using

header("Location: www.example.com/home");

bu it didn't work what are other methods to do it and not using any wp plugin for this?

Upvotes: -1

Views: 1124

Answers (3)

ashvek
ashvek

Reputation: 171

Use template redirect hook and for redirects. place below code in your themes function.php

add_action( 'template_redirect', 'mytheme_redirect' );

function mytheme_redirect(){
    // Your code
    wp_redirect( home_url() ); exit;
}

Upvotes: 0

Punit Gupta
Punit Gupta

Reputation: 4388

Go to Settings > Reading in your Admin Dashboard. Then, under Front page displays, click on A static page and select your page which you want as front page.

Upvotes: 2

maulik
maulik

Reputation: 1052

try this :- wp_redirect( 'https://example.com/home' );

Upvotes: 0

Related Questions