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

MacProductivity

Some Mac Tips

Some settings or tips I've learned over the years to make using your Mac an even nicer experience

Writing Git

How to speed up Rubocop

A small bit of config that could speed up your Rubocop runs