Sometimes, it’s the simple things that cause an issue with web development.

For example, I spent 3 hours tracking down a problem recently.

The problem:

I had set up an Nginx server on localhost to do some PHP development. I had set the configuration to rewrite all requests for .php files to go to index.php. So for example, I wanted http://localhost/login to rewrite http://localhost/index.php — so that the index.php would then process the request. Pretty typical.

But what was happening was it would go to http://localhost/login and the browser would offer to open or download the “login” file from localhost. And when I opened the file it was offering, I was getting a text file copy of index.php.

Here’s the Nginx config:

For the longest time I thought I’d done something wrong in the `location ~ \.php$ {}` block.


The solution:

Clear the browser cache.