move most of the htaccess rules to the application level