2

I have homepage which needs to redirect to another page. For this to accomplish, I used the meta fresh tag

<meta http-equiiv=refresh content="6; url=/home/">

And, it works perfectly. Later I found on Internet that this meta fresh code tag has been deprecated and is not at all SEO friendly.

Then I used one js code

<script type="text/javascript">
setTimeout("window.location='url'",5000);
</script>

and it's also working.. now, my concern is - which one still better (most SEO friendly or is there any other hack in redirecting a simple page to another WP normal page?

Thanks in advance.

4
  • If your goal is to misdirect a search engine into believing the content is there then JavaScript won't help. Google's engine is sophisticated enough to realize you're changing the URL. If your intention is to have a URL actually redirect to correct content then you'll want to use wp_redirect() as below. There isn't really a great reason to show a page for 5 seconds. Commented Jun 17, 2014 at 1:25
  • Thanks. honestly speaking, the front page is kind of a landing page with just a welcome message and with a link to the actual homepage. However, I wish the page automatically goes to the homepage (the actual homepage I mean). There is virtually no substance in the front page. However, I have also thought of noindexing the frontpage www.example.com and making the homepage www.exampple.com/home/ the actual homepage. makes sense?
    – kalyan
    Commented Jun 17, 2014 at 5:40
  • Then remove that "landing" page. Those things are just annoying. You are competing enough online without irritating your users with pointless "features"
    – s_ha_dum
    Commented Jan 9, 2016 at 15:31
  • If your concern is SEO you should do 301 redirect.
    – user16077
    Commented Oct 16, 2016 at 23:25

4 Answers 4

5

Though wp_redirect() doesn't allow a delay, PHP's header() ( which is what wp_redirect uses ) does via refresh.

This may work for you.

<?php 
  header( "refresh:5;url=wherever.php" ); 
  echo 'You\'ll be redirected in about 5 secs. If not, click <a href="wherever.php">here</a>.';
?>
3

There are two ways to do this:

1 Using wp_redirect()

Add following code to top of index.php

<?php if (is_home() || is_front_page())  wp_redirect( home_url() ); exit; ?>

Or create new page template if you are using page as front page

<?php /*  
Template Name: Page Redirect
*/ 

 wp_redirect( home_url() ); exit; 

?>

2 Using a plugin, Quick Page/Post Redirect

5
  • Kate, don't rollback my formatting. Please, when you add code to your posts, highlight the code, and check just above the editor, there are a {} sign. Click on that, your code will be automatically be added to a code block, this will display your code as in my edit Commented Jun 16, 2014 at 10:06
  • 2
    Thanks but how to use this with a timeout (redirect after a few seconds)
    – kalyan
    Commented Jun 16, 2014 at 10:30
  • You cannot. The only way to have a delayed redirection is using JS. Commented Jun 16, 2014 at 13:39
  • 1
    Yup, I hove also figured this out. So, this js code is okay? <script type="text/javascript"> setTimeout("window.location='url'",5000); </script>
    – kalyan
    Commented Jun 17, 2014 at 5:41
  • wordpress.org/support/topic/redirection-after-time
    – mrmut
    Commented Feb 16, 2020 at 22:03
0

If you are not the coding type, but you want an amazingly versatile free tool, I endorse Quick Pagepost Redirect Plugin

https://wordpress.org/plugins/quick-pagepost-redirect-plugin/

It can handle Wordpress redirects and meta redirects (in case you need a delay)

It supports 301, 302, 307, and meta redirects. You can add URL's to avoid 404's also.

If you are upgrading a site and changing page urls and wish to preserve seo ranking, this is the tool my friend uses (he's a pro)

This will do it all - no coding.

Disclaimer: I am not affiliated with these guys in any way.

-1

How about just using php sleep to delay the wp_redirect for a few seconds?

<?php
sleep(3);
wp_redirect( home_url() ); exit;
?>
1
  • i think this would not work, because you can't see the page while is "sleeping"
    – Magico
    Commented Mar 3, 2017 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.