{"id":17196,"date":"2022-11-18T18:05:48","date_gmt":"2022-11-18T12:35:48","guid":{"rendered":"https:\/\/www.milesweb.in\/hosting-faqs\/?p=17196"},"modified":"2022-11-18T18:09:23","modified_gmt":"2022-11-18T12:39:23","slug":"how-to-set-php-redirect","status":"publish","type":"post","link":"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/","title":{"rendered":"Know How to Set a PHP Redirect?"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Overview<\/h2>\n\n\n\n<p>Some of the most famous websites in the world are powered by PHP. If your website is built in PHP, it\u2019s essential to learn about the new functionality to your website, which is the PHP redirect.<\/p>\n\n\n\n<p>In this guide we\u2019ll understand how to create a PHP redirect.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating a Redirect in PHP<\/h2>\n\n\n\n<p>Create a file name index.php in the directory you want to redirect from:<\/p>\n\n\n\n<p>For eg: Here we are redirecting index.php to test.com.<\/p>\n\n\n\n<p><strong><em>&lt;?php header(&#8220;Location: http:\/\/www.redirect.to.test.com\/&#8221;); ?><\/em><\/strong><\/p>\n\n\n\n<p>Here \u201chttp:\/\/www.redirect.to.test.com\/\u201d is the URL you want the users to be redirected to.<\/p>\n\n\n\n<p>This can even be a file. Then it looks like:<\/p>\n\n\n\n<p><strong><em>&lt;?php header(&#8220;Location: anotherDirectory\/anotherFile.php&#8221;); ?><\/em><\/strong><\/p>\n\n\n\n<p>Also, make sure you change the sample URL to the URL you would like the site to forward.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Note: The above files can be of any type, but should not be limited to Python, HTML, CGI, Perl and even the CGI programs.<\/p><\/blockquote>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>PHP redirects can help search engines to navigate smoothly and securely between the pages on your website. Setting redirects in PHP is easy, and all because of the header () function.<\/p>\n\n\n\n<p>Hope this article helps!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview Some of the most famous websites in the world are powered by PHP. If your website is built in PHP, it\u2019s essential to learn about the new functionality to your website, which is the PHP redirect. In this guide we\u2019ll understand how to create a PHP redirect. Creating a Redirect in PHP Create a [&hellip;]<\/p>\n","protected":false},"author":36,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[996],"class_list":["post-17196","post","type-post","status-publish","format-standard","placeholder-for-hentry","category-howtos","tag-php-redirect"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Know How to Set a PHP Redirect? | MilesWeb<\/title>\n<meta name=\"description\" content=\"Setup the redirection process in simpler form for the PHP language. Explore through this guide and learn steps of PHP redirection.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Know How to Set a PHP Redirect? | MilesWeb\" \/>\n<meta property=\"og:description\" content=\"Setup the redirection process in simpler form for the PHP language. Explore through this guide and learn steps of PHP redirection.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-18T12:35:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-18T12:39:23+00:00\" \/>\n<meta name=\"author\" content=\"Nehal Khatri\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nehal Khatri\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/\"},\"author\":{\"name\":\"Nehal Khatri\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/93565765cf85bc4be78b4d9ccbe294bb\"},\"headline\":\"Know How to Set a PHP Redirect?\",\"datePublished\":\"2022-11-18T12:35:48+00:00\",\"dateModified\":\"2022-11-18T12:39:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/\"},\"wordCount\":209,\"commentCount\":0,\"keywords\":[\"PHP redirect\"],\"articleSection\":[\"How-Tos\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/\",\"url\":\"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/\",\"name\":\"Know How to Set a PHP Redirect? | MilesWeb\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#website\"},\"datePublished\":\"2022-11-18T12:35:48+00:00\",\"dateModified\":\"2022-11-18T12:39:23+00:00\",\"author\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/93565765cf85bc4be78b4d9ccbe294bb\"},\"description\":\"Setup the redirection process in simpler form for the PHP language. Explore through this guide and learn steps of PHP redirection.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.milesweb.in\/hosting-faqs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Know How to Set a PHP Redirect?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#website\",\"url\":\"https:\/\/www.milesweb.in\/hosting-faqs\/\",\"name\":\"Web Hosting FAQs by MilesWeb\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.milesweb.in\/hosting-faqs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/93565765cf85bc4be78b4d9ccbe294bb\",\"name\":\"Nehal Khatri\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2022\/02\/nehal-khatri-150x150.png\",\"contentUrl\":\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2022\/02\/nehal-khatri-150x150.png\",\"caption\":\"Nehal Khatri\"},\"description\":\"Nehal is an ardent content writer. She's passionate about crafting content that's simple but adds value. Her insatiable interest in writing has allowed her to explore her skills. She is adept and can write for different types of content formats.\",\"url\":\"https:\/\/www.milesweb.in\/hosting-faqs\/author\/nehal-khatri\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Know How to Set a PHP Redirect? | MilesWeb","description":"Setup the redirection process in simpler form for the PHP language. Explore through this guide and learn steps of PHP redirection.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/","og_locale":"en_US","og_type":"article","og_title":"Know How to Set a PHP Redirect? | MilesWeb","og_description":"Setup the redirection process in simpler form for the PHP language. Explore through this guide and learn steps of PHP redirection.","og_url":"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/","og_site_name":"Web Hosting FAQs by MilesWeb","article_published_time":"2022-11-18T12:35:48+00:00","article_modified_time":"2022-11-18T12:39:23+00:00","author":"Nehal Khatri","twitter_misc":{"Written by":"Nehal Khatri","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/#article","isPartOf":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/"},"author":{"name":"Nehal Khatri","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/93565765cf85bc4be78b4d9ccbe294bb"},"headline":"Know How to Set a PHP Redirect?","datePublished":"2022-11-18T12:35:48+00:00","dateModified":"2022-11-18T12:39:23+00:00","mainEntityOfPage":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/"},"wordCount":209,"commentCount":0,"keywords":["PHP redirect"],"articleSection":["How-Tos"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/","url":"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/","name":"Know How to Set a PHP Redirect? | MilesWeb","isPartOf":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#website"},"datePublished":"2022-11-18T12:35:48+00:00","dateModified":"2022-11-18T12:39:23+00:00","author":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/93565765cf85bc4be78b4d9ccbe294bb"},"description":"Setup the redirection process in simpler form for the PHP language. Explore through this guide and learn steps of PHP redirection.","breadcrumb":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/how-to-set-php-redirect\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.milesweb.in\/hosting-faqs\/"},{"@type":"ListItem","position":2,"name":"Know How to Set a PHP Redirect?"}]},{"@type":"WebSite","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#website","url":"https:\/\/www.milesweb.in\/hosting-faqs\/","name":"Web Hosting FAQs by MilesWeb","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.milesweb.in\/hosting-faqs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/93565765cf85bc4be78b4d9ccbe294bb","name":"Nehal Khatri","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/image\/","url":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2022\/02\/nehal-khatri-150x150.png","contentUrl":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2022\/02\/nehal-khatri-150x150.png","caption":"Nehal Khatri"},"description":"Nehal is an ardent content writer. She's passionate about crafting content that's simple but adds value. Her insatiable interest in writing has allowed her to explore her skills. She is adept and can write for different types of content formats.","url":"https:\/\/www.milesweb.in\/hosting-faqs\/author\/nehal-khatri\/"}]}},"_links":{"self":[{"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/posts\/17196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/users\/36"}],"replies":[{"embeddable":true,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/comments?post=17196"}],"version-history":[{"count":2,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/posts\/17196\/revisions"}],"predecessor-version":[{"id":17198,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/posts\/17196\/revisions\/17198"}],"wp:attachment":[{"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/media?parent=17196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/categories?post=17196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/tags?post=17196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}