If you sell your shares on the ex-date, i.e. July 22nd, the shares will be removed from your account the next day by your stockbroker. On the record date, the stockbroker will be marked as the shareholder in the records of the Registrar of the company and will receive the REs. However, since the shares belonged to you, the REs will then be transferred by the stockbroker to your account once they’re listed.
You will then be able to apply for the rights shares or you can sell the REs directly in the secondary markets.