Flying Ad‐hoc Networks (FANETs) has recently gained significant exposure for their emerging military, civil, and commercial applications. In FANETs, all Unmanned Aerial Vehicles (UAVs) can communicate within a restricted wireless communication range without fixed infrastructure. However, the highly dynamic nature of UAVs imposes a significant issue in FANET's communications. Therefore, designing an effective routing strategy is always necessary for sustaining appropriate network performance in FANETs. This paper is interested in modifying Greedy Perimeter Stateless Routing (GPSR) protocol named Utility Function based Greedy Perimeter Stateless Routing (UF‐GPSR) protocol for FANETs. The proposed approach optimizes the greedy forwarding strategy by considering multiple vital parameters of UAVs: residual energy ratio, distance degree, movement direction, link risk degree, and speed, respectively. The proposed UF‐GPSR applies the utility function on these parameters to enhance the routing performance by selecting optimal next‐hop within the communication range. The effectiveness of the proposed work is mathematically evaluated and then simulated through the NS‐3.23 simulator. The experimental outcomes verify that the proposed routing approach enhances the packet delivery ratio and throughput while decreasing packet drop ratio and delay compared to the other routing approaches: GPSR and GPSR‐PPU.