{"id":81,"date":"2012-02-14T04:32:00","date_gmt":"2012-02-14T04:32:00","guid":{"rendered":"http:\/\/pheonixsolutions.com\/?p=81"},"modified":"2026-06-22T09:39:45","modified_gmt":"2026-06-22T04:09:45","slug":"wordpress-index-file","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/wordpress-index-file\/","title":{"rendered":"How to Restore the WordPress index.php File"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>index.php<\/code> file is one of the main core files of a WordPress website. It is located in the WordPress root directory and is responsible for loading the WordPress environment and theme. When a visitor opens the website, this file helps WordPress load the required files and display the website properly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sometimes, the <code>index.php<\/code> file may be modified, corrupted, deleted, or infected due to malware or website hacking. If the WordPress index file is hacked or damaged, the website may show a blank page, redirect to another website, display unwanted content, or stop loading completely.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide explains how to restore the default WordPress <code>index.php<\/code> file safely.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before restoring the WordPress <code>index.php<\/code> file, make sure you have the following:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>cPanel, FTP, SSH, or File Manager access.<\/li>\n\n\n\n<li>Access to the WordPress website root directory.<\/li>\n\n\n\n<li>Backup of the current website files.<\/li>\n\n\n\n<li>Basic knowledge of WordPress file structure.<\/li>\n\n\n\n<li>Permission to edit or replace the <code>index.php<\/code> file.<\/li>\n\n\n\n<li>Malware scan report, if the website was hacked.<\/li>\n\n\n\n<li>Latest clean WordPress core files for reference.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Implementation Steps<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Log in to cPanel or Server<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Log in to your hosting control panel, cPanel, FTP, or SSH.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you are using cPanel, open:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cPanel \u2192 File Manager\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Open the WordPress Root Directory<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Go to the WordPress installation directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Common WordPress root paths are:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/public_html\n\/public_html\/domain.com\n\/home\/username\/public_html\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You should see files like:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">index.php\nwp-config.php\nwp-blog-header.php\nwp-admin\nwp-content\nwp-includes\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Take a Backup of the Existing index.php File<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Before making any changes, download or rename the existing <code>index.php<\/code> file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">index.php-old\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This helps you keep a copy of the previous file for checking or investigation.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Check Whether index.php Is Hacked<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Open the existing <code>index.php<\/code> file and check for suspicious code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A hacked WordPress <code>index.php<\/code> file may contain:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">base64_decode\neval\ngzinflate\nshell_exec\niframe\nunknown script URLs\nautomatic redirect code\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you find suspicious code, the file should be replaced with the default WordPress index file.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Replace with the Default WordPress index.php Code<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create or edit the <code>index.php<\/code> file and add the below default WordPress code:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\/**\n * Front to the WordPress application. This file doesn't do anything, but loads\n * wp-blog-header.php which does and tells WordPress to load the theme.\n *\n * @package WordPress\n *\/\n\n\/**\n * Tells WordPress to load the WordPress theme and output it.\n *\n * @var bool\n *\/\ndefine('WP_USE_THEMES', true);\n\n\/** Loads the WordPress Environment and Template *\/\nrequire('.\/wp-blog-header.php');\n?>\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Save the file after updating the code.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Step 6: Set Correct File Permission<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Make sure the <code>index.php<\/code> file has the correct permission.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Recommended permission:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">644\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you are using SSH, you can run:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">chmod 644 index.php\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Step 7: Clear Website Cache<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">After restoring the file, clear all caches.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Clear cache from:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">WordPress cache plugin\nServer cache\nBrowser cache\nCDN cache\nCloudflare cache, if used\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Step 8: Test the Website<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Open the website in a browser and confirm that it is loading properly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also check:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Homepage\nAdmin login page\nInner pages\nPosts\nContact form\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">WordPress admin login URL:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">https:\/\/yourdomain.com\/wp-admin\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Step 9: Scan the Website for Malware<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If the <code>index.php<\/code> file was hacked, scan the full website because the same malware may exist in other files also.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check important folders:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">wp-admin\nwp-content\nwp-includes\nplugins\nthemes\nuploads\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can also check recently modified files from SSH:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">find . -type f -mtime -7\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This command shows files modified in the last 7 days.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Step 10: Update WordPress Core, Themes, and Plugins<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">After restoring the file, update WordPress and all plugins\/themes to reduce security risk.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Update:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">WordPress core\nThemes\nPlugins\nPHP version\nSecurity plugin rules\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Remove unused themes and plugins if they are not required.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The WordPress <code>index.php<\/code> file is a core file required to load the WordPress website. If this file is hacked, modified, or deleted, the website may stop working or show unwanted redirects and malicious content.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By replacing the infected or corrupted <code>index.php<\/code> file with the default WordPress code, the website can be restored quickly. However, replacing only the <code>index.php<\/code> file is not enough if the website was hacked. A full malware scan, plugin\/theme update, and security review should also be completed to prevent the issue from happening again.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction The index.php file is one of the main core files of a WordPress website. It is located in the [&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_feature_clip_id":0,"_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-81","post","type-post","status-publish","format-standard","hentry","category-web-architecture","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-1j","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/81","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=81"}],"version-history":[{"count":1,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/81\/revisions"}],"predecessor-version":[{"id":10396,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/81\/revisions\/10396"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=81"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=81"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}