Fix the @admin redirect for application URLs

Included unit test for this function.