Here is the text of Matthew 16:18 set out in Greek of Nestle-Aland 27 and English of ESV (as above):
κἀγὼ δέ σοι λέγω ὅτι σὺ εἶ Πέτρος,
kagō de soi legō hoti su ei Petros
And I tell you, you are Peter,
καὶ ἐπὶ ταύτῃ τῇ πέτρᾳ οἰκοδομήσω μου τὴν ἐκκλησίαν
kai epi tautē tē(i) petra(i) oikodomēsō mou tēn ekklēsian
and on this rock I will build my church,
καὶ πύλαι ᾅδου οὐ κατισχύσουσιν αὐτῆς.
kai pulai ha(i)dou ou katischusousin autēs
and the gates of hell shall not prevail against it.
The answer to the presenting question ("According to the original Greek, which "rock" is the word "this" actually being assigned to?") is simple, in grammatical terms: ἐπὶ ταύτῃ τῇ πέτρᾳ (epi tautē tē(i) petra(i)) "upon this rock" refers to Peter.
The Greek word πέτρα (petra) is one of the standard Greek words for "rock, stone", more "rock" than "stone", the other being λίθος (lithos) (more "stone" than "rock").
As Max Wilcox writes, in an important article for this question:
The plain meaning of v. 18 as it stands is quite simply that the Church (of Jesus) is to be built upon Peter.1
So the grammatical question is simple, and the immediate referent clear.2 But, as Wilcox immediately goes on to notice,
But elsewhere in the NT and in early patristic literature it is not upon Peter but upon Christ that the Church is built. Moreover, apart from this one passage, the 'stone' and 'rock' motifs from the OT are clearly applied to Jesus or to God. Why should it have been otherwise here?
And this is the deeper question to which the word "actually" in OP's forumlation points. Here things can get intricate and involved. In the history of the interpretation of this passage, two factors in particular come into play:
- the Aramaic, kēphaʾ (but perhaps also the Hebrew), lying behind the Peter/petra wordplay, which comes into a related text, John 1:42 ('Jesus looked at him and said, "So you are Simon the son of John? You shall be called Cephas" (which means Peter).');
- the editorial unity of these few verses, as some commentators argue that the basic scene has been elaborated by later tradition.
To unpack these would take this answer far beyond the time and space I have available; perhaps others will take up the story. To investigate further, do consult the material cited here (available in any decent seminary library). Also:
I hope this helps at least at a basic level.
- Max Wilcox, "Peter and the Rock: A Fresh Look at Matthew xvi. 17–19", New Testament Studies 22/1 (October 1975): 73-88 (quote on p. 84).
- So too A.B. Bruce, in W. Robertson Nicoll (ed.), The Expositor's Greek Testament (London: Hodder and Stoughton, 1897), vol. 1, pp. 224-225.