Fixed redirect for localhost in option 2 rewrite

In the .htaccess file option 2 rewrite rules, which prepends "www." to
URLs, could break applications running on a local environment. If
option 2 was enabled, http://localhost or http://127.0.0.1 would
redirect to http://www.localhost or http://www.127.0.0.1 which caused
an error and prevents the app from being tested locally. Added
exceptions to the rewrite conditions to prevent this.