Yes it would apply. It would apply to the proportion of time you rented it, although last 9 months are counted as if you lived there, even if it was rented for this time, so there is no benefit in moving back for a short period.
Period of rent would be 5.25 years. 5.25 is approx 31% of total ownership period (i assumed 17 years is period you lived in and rented combined). Chargeable gain is circa £31k. You can use cgt allowance of £12,300 (2 lots if jointly owned) to reduce this and then you pay 18% or 28% on balance.
God that tax is outrageous. I only live away from home following redundancy and the need to secure employment meant moving to another part of the country !