Etymology
The name rock fort comes from the fact that the place was used for military fortification first by the Vijayanagar emperors and later by the British during the Carnatic wars
Architecture
The Rock Fort temple stands 83m tall perched atop the rock. The smooth rock was first cut by the Pallavas but it was the Nayaks of Madurai who completed both the temples under the Vijayanagara empire.
The temple complex is composed of two parts: a Shiva temple (Thayumanaswamy) carved in the middle of the rock and a Pillayar (Ganesh)temple at the top portion of the rock[1]. The Shiva temple is the bigger one, housing a massive stone statue of Shiva in the form of Linga along with a separate sanctum for goddess Parvati. The temple is mystic in its nature with an awe-inspiring rock architecture. The Ganesh temple is much smaller with an access through steep steps carved on the rock and provides a stunning view of Trichy, Srirangam and the rivers Kaveri and Kollidam. Due to its ancient and impressive architecture created by the Pallavas, the temple is maintained by the Archaeological department of India.
Mythology of the Vinayaka temple
Vibhishana, was the younger brother of the Asura King Ravana who ruled Lanka (now known as Srilanka). Lord Rama in the epic of Ramayana rescues his wife Sita, who was kidnapped and held by Ravana, with the help of Sugriva and Hanuman defeated him. In this war, the moral and truth-abiding brother of Ravana, Vibishana aids Rama in his battle against his brother. Ultimately Rama wins the war and as a token of love, He gifts Vibishana an Idol of Lord Ranganatha, a form of Vishnu.
Vibhishana, though he supported Rama, was basically an Asura, hence the Devas (who are arch rivals to Asuras as per Hindu mythology) wanted to stop this idea of an Asura taking Lord's supreme form to his Kingdom. They request the help of the God of Happiness, Lord Vinayaka and the Lord accepts the plan. Vibhishana, while on his back to his Kingdom, goes through Trichi, and wanted to take his bath in the river Kaveri and do his daily rituals. However, he is perplexed as the idol once kept in land, can never be removed and has to be in that place forever.
As a solution, Vibishana tries to find someone to hold the idol while he was taking bath and finds the Lord Vianayaka under disguise of a cowherd boy. As per the plan, when Vibishana is fully into water, Vinayaka takes the statues and keeps it firmly in sand, in the banks of kaveri. On seeing this, the angry Vibhishana chases the boy, to punish him, and boy keeps running and climbs over the rock near the Kaveri bank. Vibhishana finally reaches the boy and hits him on the fore-head of little boy who then reveals himself to be Vinayaga. Vibishana immediately apoligizes and the Lord gives him his blessings and sends him off to Lanka.
The place on which the Ranganathan idol was kept was later covered in deep forests, due to disuse and after a very long time, it is discovered when a Chola king chasing a parrot finds the idol accidentally. He then establishes the Ranganathaswamy temple,Srirangam as one of the largest temple complexes in the world. Meanwhile, the Pallavas built the Vinayaka temple and the Thayumanaswamy temple, in the rock which Vinayaka uses to escape Vibishana.