Quickly Set Up a Templating System Using .htaccess
Setting up a website capable of easy template switching probably sounds difficult. When I first thought about building a templating system, it felt like a pretty daunting task. After tinkering around for a few days, I found a way that would allow me to switch templates by simply changing a .htaccess directive.
The Folder Structure
+ root + templates + version1 - css - graphics - js + version2 - css - graphics - js + version3 - css - graphics - js
The .htaccess Directives
RewriteRule ^css/(.*) /templates/version2/css/$1 RewriteRule ^graphics/(.*) /templates/version2/graphics/$1 RewriteRule ^js/(.*) /templates/version2/js/$1
The .htaccess directives change the request paths from the root level to the current template's folder. Essentially, to switch themes, all you need to do is change the template folder in the .htaccess file.
What are your thoughts? Is there a better way to go about this? If so, please share.