Can you go inside the Koutoubia mosque?

The short answer

No.

Non-Muslims cannot enter the Koutoubia, or virtually any mosque in Morocco. The restriction dates to the French protectorate era and has remained in place since. Two exceptions: the Hassan II Mosque in Casablanca (guided tours daily) and the Tinmel Mosque in the High Atlas.