Unambiguous tracking and multipath mitigation for Binary Offset Carrier (BOC) signals are two important requirements of modern Global Navigation Satellite Systems (GNSS) receivers. A GNSS discriminator design method based on optimization technique is proposed in this paper to meet these requirements. Firstly, the discriminator structure based on a linear-combined code is given. Then the requirements of ideal discriminator function are converted into the mathematical constraints and the objective function to form a non-linear optimization problem. Finally, the problem is solved and the local code is generated according to the results. The theoretical analysis and simulation results indicate that the proposed method can completely remove the false lock points for BOC signals and provide superior multipath mitigation performance compared with traditional discriminator and high revolution correlator (HRC) technique. Moreover, the proposed discriminator is easy to implement for not increasing the number of correlators.