Magento admin panel gives 404 when trying to enter CMS pages

You are getting a 404 on CMS pages because of the remains of old store views still hanging around in the database after deleting store views from Magento admin, to clean up ( delete ) old unused CMS pages for store views you have deleted run this MySQL query.

DELETE FROM cms_page_store WHERE store_id NOT IN (SELECT store_id FROM core_store)