Ride-by attack with a lance

I am currently mastering a game of Pathfinder with a few friends, and a situation occured during a game.

The cavalier which has a few mounted feats (including ride-by attack), charges.

He asked if he could charge two squares away from the target and hit him with the reach of the lance. I simply didn’t know what to answer at the time so i allowed it, but it then seemed a bit off. What do you think?