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

SEO

Google follows URLs in text

Today I learned that Google follows URLs even when they are plain text

Web Dev

Check in with your database

It pays to take a step back and look at how your database is set up every so often. You will often find quick wins and hidden tech debt.