01 - Preheat oven to 375°F. Grease a 9x13 inch baking dish.
02 - Boil salted water in a large pot and cook ziti until just al dente. Drain and set aside.
03 - Heat olive oil in a skillet over medium heat. Sauté onion until translucent, about 4 minutes. Add garlic and cook for 1 minute.
04 - Add crushed tomatoes, tomato paste, oregano, basil, salt, black pepper, and red pepper flakes if using. Simmer uncovered for 10 minutes, stirring occasionally.
05 - In a bowl, combine ricotta, Parmesan, egg, and parsley. Mix thoroughly until smooth.
06 - Spread a thin layer of tomato sauce in the baking dish. Layer half the pasta, half the ricotta mixture, half the mozzarella, and some sauce. Repeat layers. Top with extra Parmesan.
07 - Cover with foil and bake for 25 minutes.
08 - Remove foil and bake an additional 10 to 15 minutes until cheese is bubbly and golden brown.
09 - Allow to rest for 10 minutes before slicing and serving.