As I said, never edit core files, because when you upgrade your Magento version in the future it will break your store like nothing.
Maybe you might think that you won’t need any updates, but trust me, when there will be some nasty security vulnerability (It happend to WordPress many times) last thing you would want is to expose your customers credentials.
In order to be able to create controller, you need to have your own module. If you don’t know how to create one, follow this tutorial first. If you have never made any controllers follow this guide, where I explained how it works.
Of corse you need to know which controller you want to rewrite. Let’s say we want to change product details and replace it for our own page.
When you visit page with product, open developers tools to see the source code. You will see that body is catalog-product-view, which in our case means that module catalog, ProductController.php and method viewAction() take care about this page.
If we want to override route from the core Magento controller, we will need to define exactly the same route. Because we now know which module takes care about the product page we can navigate to the module’s config.xml file which is here app/code/core/Mage/catalog/etc/config.xml
You will see the only one route which is defined here. Copy that to your own module config file and slightly. Your module /etc/config.xml file should has following code in it. My company name is in this case Lukas and module name is Test. Watch out capital letters.
<config> <frontend> <routers> <catalog> <use>standard</use> <args> <modules> <test before="Mage_Catalog">Lukas_Test</test> </modules> <frontName>catalog</frontName> </args> </catalog> </routers> </frontend> </config>
Last thing what we need to do is to create controller. In your module folder create /controllers/ProductController.php.