President Barack Obama visited an American mosque on Wednesday and declared that attacks on Islam were an attack on all religions, in an effort to counter rhetoric from Donald Trump and other Republican presidential candidates that has alienated Muslims.