An Exploration-by-Optimization Approach to Best of Both Worlds in Linear Bandits