fixed env var generate each; added apache rewrite and local dirs