Top tip: Only use one .htaccess
Disclaimer: I’m trying to write this in under 7 minutes
It’s been a fun day, and we’ve learnt something from this:
Only use one .htaccess file for mod_rewrites.
- Say I have my site, path-wise located at /
- My site also has a shop, located at /shop/
Now, it’s really tempting to have a /.htaccess file containing all my rewrites for my site, and a separate /shop/.htaccess file which holds just the shop-specific rewrites. It’s modular, it’s scalable, it’s clear.
It’s a mistake.
The problem is that your /shop/.htaccess not only overrides /.htaccess for all the /shop/.* URLs, but it actually *disables* all the rewrites for /.htaccess. This is a problem if for example you one day decide to do any mass site-wide redirects, such as domain or protocol canonicalisation. Cleaning up those old URLs can be a problem too.
However, I like modulation so I’m going to do some thinking about this and see what I can come up with as a solution.
Enjoy your weekend!