Do not set #dir when on public.php

Fix #7571 

@schiesbn @PVince81