In wireless sensor networks, location-aware applications require an accurate and robust sensor localization algorithm. Among them, most of the multihop-based localization algorithms approximate the shortest path distances to the Euclidean distances. This approximation is valid only if the sensors are uniformly and densely deployed in a convex area where the shortest paths are close to straight lines. However, in a real- world setting, the convexity assumption may not always be valid. Non-convex deployment areas, such as C-shaped or S-shaped topologies, can corrupt the localization results severely due to erroneous distance estimations distorted by the non-convex topology. In this paper, we formulate the localization problem in irregular areas as a constrained least-penalty problem. We then propose a two-phase algorithm to eliminate the impact of irregularities. In the first phase, the estimated position is confined in the intersection area of the communication range constraints. In the second phase, the distorted measurements are eliminated by using a robust position estimator. Simulation results show that the two-phase algorithm outperforms some of the existing multihop localization algorithms in terms of a lower average localization error in both C-shaped and S-shaped topologies. The effects of anchor density, range error and communication range on localization performances are studied as well.