A bomb targeting a Cairo court exploded Tuesday just before polling stations were to open for a constitutional referendum boycotted by supporters of ousted president Mohamed Morsi, an interior ministry official said.