-1

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?

2
  • Why don't you choose the home page in the Wordpress settings and it will automatically go to that page? Its rather unusual to need to redirect to your homepage in the code. If you let us know the reason you want to do it that way, we might have a better solution. Commented Aug 25, 2017 at 6:28
  • Prefer to use wordpress settings, rather than writing PHP snippets. Commented Aug 25, 2017 at 6:29

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

0

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; } 

1 Comment

This is needed only if you need redirects, to set a static page as home page go to Admin Dashboard => Settings => Reading => Front page displays, click on a static page and select your page which you want as homepage.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.