In a saucepan, combine the granulated sugar and water. Bring to a boil over medium heat, stirring occasionally.
Once the sugar has completely dissolved, reduce the heat and simmer for 10 minutes.
Add the lemon juice and simmer for an additional 2-3 minutes.
Remove from heat and stir in the rose water or orange blossom water, if using. Allow the syrup to cool to room temperature.
Preheat your oven to 350°F (175°C). Grease a 9x13-inch baking dish with some of the melted butter.
If using knafeh (shredded phyllo dough), separate the strands and place them in a large bowl. Pour in the melted butter and toss to coat evenly.
Press half of the buttered knafeh into the bottom of the prepared baking dish, smoothing it into an even layer.
In a bowl, mix together the ricotta cheese, sugar, and ground cinnamon. Spread this mixture evenly over the knafeh layer in the baking dish.
Top with the remaining knafeh, pressing it down gently.
Bake in the preheated oven for 30-35 minutes, or until the top is golden brown and crispy.
Remove from the oven and immediately pour the cooled syrup evenly over the hot knafeh. Allow it to soak in for about 10-15 minutes.
Garnish with chopped pistachios before serving.
Enjoy your meal!