Automatic dir and URL detection