CakePHP and htaccess caching funtimes

An issue I had with CakePHP and htaccess and how I fixed it

I wanted to fire up a quick post about my CakePHP and htaccess caching issue — So I was working on a CakePHP project and I was pulling my hair out wondering why a development site was redirecting to a production site, the issue was quickly narrowed down the the .htaccess file which was uploaded to the development area in error — it contained some redirect rules that were kicking in.

So I logged into the development machine and removed the offending htaccess rules, refreshed the page but the issue was still happening.

The reason was that the development server had also had the config file for the production server which has CakePHP caching turned on.

The main take away here is that your .htaccess can potentially get cached by CakePHP, this isn't something I had thought would happen and until there is a problem you might never consider this as an issue.

The second take away is that the code shouldn't have needed to be kept separate between development and production, this is something I am going to look at improving on some projects.

In my case the fix was to clear the cache, once Cake had picked up the new .htaccess file everything was grand again.

Going forward I am going to make sure that when I make changes any files on a CakePHP project I will refresh the cache, just to play it safe.

 


Recent posts View all

Ruby

How to ignore Bullet in RSpec tests

Using Bullet during a test can pick up mistakes but also has false negatives; here is an easy way to ignore them

Ruby

How we used Nokogiri to fix a sizing issue in YouTube's oEmbed

At some point, one of our calls to YouTube's oEmbed endpoint was returning videos way too small; we fixed in in our Rails application by using Nokogiri