I control a portal, and on this portal there is a mod that I placed. It's a common mod, and I would like to replace it with a better mod, a very rare one. Is there a way I can replace the current mod with the better one?
You can't upgrade a mod (yours or not) directly.
If you really need a mod changed and you have enough time, you can use a virus (jarvis or ada) to switch the portal to the other faction, attack it with ultra strike until there is only one or zero mods, and (one hour later) virus the portal back to your faction.
Be careful, if there are still two mods on the portal, after the second virus they will both be taggued with your name, so you will not be able to add another mod. That's why if you don't have another agent to help you, you have to destroy all mods but one, and you can't choose.