Do not set #dir when on public.php

Fix #5758 

@schiesbn @PVince81