{"id":140,"date":"2011-12-24T15:03:49","date_gmt":"2011-12-24T15:03:49","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=140"},"modified":"2026-02-13T01:11:32","modified_gmt":"2026-02-13T01:11:32","slug":"redirect-and-reload","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/php\/page-control\/redirect-and-reload","title":{"rendered":"Redirect and Reload"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Before outputting page content<\/h4>\n\n\n\n<p>Note this must be before any html headers are sent (i.e. in php code before html output) <\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Redirect to a new page<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\theader(\"Location: index.php\");\n\tdie();<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Reload the current page <\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\theader('Location: '.$_SERVER&#91;'PHP_SELF']);\n\tdie;<\/code><\/pre>\n\n\n\n<p> <a rel=\"noopener noreferrer\" href=\"http:\/\/php.net\/manual\/en\/function.header.php\" target=\"_blank\">The php header function<\/a> <\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Redirect with check you&#8217;re not already on target page<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  if (strpos($_SERVER&#91;\"REQUEST_URI\"], 'home-holding') === False)\n  {\n    wp_redirect( home_url( '\/home-holding') );\n    die;\n  }<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">If you&#8217;ve outputted some page content<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">JavaScript method<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  $HtmlOutput .= &lt;&lt;&lt;_END\n    &lt;script>\n      window.location = \"https:\/\/somedomain.com\";\n    &lt;\/script>\";\n_END;<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Using META tag method<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;META HTTP-EQUIV=\"refresh\" content=\"0;URL=index.php\"&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Before outputting page content Note this must be before any html headers are sent (i.e. in php code before html output) Redirect to a new page Reload the current page The php header function Redirect with check you&#8217;re not already on target page If you&#8217;ve outputted some page content JavaScript method Using META tag method<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-140","post","type-post","status-publish","format-standard","hentry","category-page-control"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=140"}],"version-history":[{"count":9,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/140\/revisions"}],"predecessor-version":[{"id":5287,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/140\/revisions\/5287"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}