Refactored WebEnvironment and trailing slash handling