{"id":163,"date":"2011-11-20T00:17:00","date_gmt":"2011-11-20T00:17:00","guid":{"rendered":"http:\/\/pheonixsolutions.com\/?p=163"},"modified":"2026-05-03T13:53:15","modified_gmt":"2026-05-03T08:23:15","slug":"php-redirection-in-index-php","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/php-redirection-in-index-php\/","title":{"rendered":"How to perform PHP redirection in index.php"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">PHP redirection is a method used to automatically send users from one page to another using server-side scripting. In most websites, the <code>index.php<\/code> file acts as the entry point, and redirection is commonly used there to route visitors to the correct landing page, login page, or application dashboard.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Unlike client-side redirects (JavaScript or meta tags), PHP redirection happens at the server level, making it faster, more secure, and SEO-friendly when implemented correctly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before implementing PHP redirection in <code>index.php<\/code>, make sure you have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Access to your website files via hosting panel or FTP<\/li>\n\n\n\n<li>A working PHP-enabled server environment<\/li>\n\n\n\n<li>Basic knowledge of file structure (especially <code>index.php<\/code>)<\/li>\n\n\n\n<li>Clear understanding of source and destination URLs<\/li>\n\n\n\n<li>Proper permissions to edit the <code>index.php<\/code> file<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">IMPLEMENTATION<\/h2>\n\n\n<p>Paste following lines in index.php with appropriate changes. \ud83d\ude09<\/p>\n<p><!--?php &lt;br ?-->header(&#8220;Location: http:\/\/domain to be redirected&#8221;); \/\/302 redirect<br \/>exit;<br \/>?&gt;<\/p>\n<p>Example:<br \/>&#8220;&#8220;&#8220;&#8220;&#8220;&#8220;&#8220;<br \/><!--?php &lt;br ?-->header(&#8220;Location: http:\/\/google.com&#8221;); \/\/302 redirect<br \/>exit;<br \/>?&gt;<\/p>\n<h2>Conclusion<\/h2>\n<p>PHP redirection in <code data-start=\"2011\" data-end=\"2022\">index.php<\/code> is a simple yet powerful technique to control user navigation at the server level. It is widely used for landing page routing, domain migration, login protection, and application flow control. When implemented correctly, it ensures smooth user experience, better security, and improved website management.<\/p>","protected":false},"excerpt":{"rendered":"<p>Introduction PHP redirection is a method used to automatically send users from one page to another using server-side scripting. In [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[],"class_list":["post-163","post","type-post","status-publish","format-standard","hentry","category-web-architecture","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-2D","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=163"}],"version-history":[{"count":1,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/163\/revisions"}],"predecessor-version":[{"id":10097,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/163\/revisions\/10097"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}