Intercept and adjust local URLs properly

This is now mostly working.