The country on whose territory you are standing -- whether or not you are admitted into a country or not upon presentation of yourself at the port of entry -- is how it usually is. An ordinary traveler being refused entry at the country's port of entry when on that country's soil generally provides no protection from being subjected to the jurisdiction of the country where that ordinary person is physically located at the time.