{"id":690,"date":"2018-10-02T17:32:11","date_gmt":"2018-10-02T16:32:11","guid":{"rendered":"https:\/\/www.onfocus.co.uk\/?p=690"},"modified":"2018-10-02T17:32:11","modified_gmt":"2018-10-02T16:32:11","slug":"php-on-page-301-redirect","status":"publish","type":"post","link":"https:\/\/www.onfocus.co.uk\/blog\/php-on-page-301-redirect\/","title":{"rendered":"PHP on page 301 redirect"},"content":{"rendered":"<p>I needed to redirect traffic from one page to another without using the .htaccess file.<\/p>\n<p>I also wanted to let any search engines know that may have indexed the file of its new location.<\/p>\n<p>By using a 301 redirect it would let search engines know to index the new page instead of the original page.<\/p>\n<p>As the page was a .php I have achieved this redirect by using the following PHP (PHP: Hypertext Preprocessor) code:<\/p>\n<pre>&lt;?php\r\nheader(\"HTTP\/1.1 301 Moved Permanently\");\r\nheader(\"Location: https:\/\/www.example-samesite.com\/new-page.php\");\r\nexit();\r\n?&gt;<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I needed to redirect traffic from one page to another without using the .htaccess file. I also wanted to let any search engines know that may have indexed the file of its new location.&#46;&#46;&#46;<\/p>\n","protected":false},"author":4,"featured_media":693,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[47],"tags":[48],"class_list":["post-690","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-website-design","tag-php"],"_links":{"self":[{"href":"https:\/\/www.onfocus.co.uk\/blog\/wp-json\/wp\/v2\/posts\/690","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.onfocus.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.onfocus.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.onfocus.co.uk\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.onfocus.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=690"}],"version-history":[{"count":5,"href":"https:\/\/www.onfocus.co.uk\/blog\/wp-json\/wp\/v2\/posts\/690\/revisions"}],"predecessor-version":[{"id":696,"href":"https:\/\/www.onfocus.co.uk\/blog\/wp-json\/wp\/v2\/posts\/690\/revisions\/696"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.onfocus.co.uk\/blog\/wp-json\/wp\/v2\/media\/693"}],"wp:attachment":[{"href":"https:\/\/www.onfocus.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.onfocus.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.onfocus.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}