Preheat your oven to 375°F (190°C).
Cook the rigatoni pasta according to package instructions until al dente. Drain and set aside.
In a large skillet, heat the olive oil over medium heat. Add the diced onion and sauté until translucent, about 5 minutes.
Add the minced garlic and cook for an additional minute until fragrant.
Add the ground beef or sausage to the skillet, breaking it apart with a spoon. Cook until browned and cooked through, about 6-8 minutes. Drain excess fat if necessary.
Stir in the marinara sauce, oregano, basil, red pepper flakes, salt, and pepper. Simmer for 5 minutes.
In a large mixing bowl, combine the cooked rigatoni, meat sauce, and ricotta cheese. Mix until well combined.
Transfer the mixture to a greased 9x13-inch baking dish. Top with shredded mozzarella and grated Parmesan cheese.
Bake in the preheated oven for 25-30 minutes, or until the cheese is bubbly and golden brown.
Let it cool for a few minutes before serving. Garnish with fresh basil if desired.