Index.php Wouldn’t Load Correctly

Jan 12 2017

I managed to screw up my website at some point. Index.php would not load correctly. You would instead be prompted to download a file. Other WordPress websites in my hosting package worked correctly and other PHP pages in this website worked — just not index.php.

I casually troubleshooted it at times and kept being pointed to htaccess or the PHP configuration being the problem but nothing I found worked. Today I decided to get to the bottom of it. Obviously it was something relatively simple since the other sites and pages worked, I just had to find it. I compared the htaccess file between this site and another similar WordPress site I have. Both were exactly the same. There were some permission differences between the directory structures — mostly the “group” part of the permissions didn’t have read and/or execute rights on this site. Changing the permissions didn’t change the behavior.

Finally I saw a comment about having an index.html in the root directory of the site. I didn’t have that file but I did have index.html.old and index.php.old. I don’t remember what either of those were used for but I moved them both out of the directory. Boom! The site loads correctly now. I went a little further to figure out if one or both of the files was the actual problem and it turns out index.html.old was the issue. So even though it wasn’t named index.html (or index.htm), apparently Apache found it and tried to load it instead of index.php.

No responses yet