ALABAMA’S LAW targeting illegal immigrants has been partly gutted by federal judges, who found key provisions unconstitutional; attacked by agricultural interests, which say it has created labor shortages in the fields; and assailed by business groups, which fear it is fostering a hostile economic climate. Shortly after the law took effect last fall, a visiting German executive from Mercedes-Benz was detained for hours by police. Oops. Officers said that under the new law, they had no choice but to check his legal status when all he could show them was a German ID.

Undeterred, state lawmakers have refused to repeal the law. Instead, they are tweaking it in hopes of avoiding such embarrassments and running further afoul of the courts. In the process, though, they may make matters worse.

A bill containing modifications, now making its way through the state legislature, leaves intact many of the law’s original features — those that have survived judicial review, at least. In other cases it makes a harsh bill harsher.

One revision concerns the obligation of police to check the legal status of individuals who are detained. Under the proposed rewrite, officers would be required to conduct such checks only if they make an arrest or issue a traffic ticket. But that’s not much of an improvement, given that police can almost always issue a traffic citation if they’re so inclined.

Worse, the proposed law would require police to check the legal status of passengers in a vehicle if they suspect the driver is an illegal immigrant. That provision, unique among the states, invites racial profiling and unwarranted harassment of people who are doing nothing more than riding in a car.

Another revision would relieve public schools of the obligation to check on the immigration status of students, although they would still be allowed, and possibly encouraged, to do so.

Religious groups have worried that the law makes it illegal for them to provide services to needy immigrants who are undocumented; in some ways the revisions would compound that absurdity. Whereas the existing law makes it a felony to assist 10 or more illegal immigrants — even by giving them a ride to work — the revision would lower the threshold to five.

In an attempt to assuage corporations, the legislation would modify the requirement that a firm’s business license be revoked if it is found guilty of a second instance of hiring illegal workers. However, the revised standard, which would allow firms’ licenses to be revoked after a third violation if a court decides revocation serves the public’s interest, seems to protect big employers while leaving small businesses vulnerable. That’s blatantly unfair.

Alabama has devised a solution in search of a problem. Though relatively few undocumented immigrants lived in Alabama in the first place, the thousands who did have fled, as lawmakers hoped. The cost has been to cement Alabama’s reputation for intolerance, raise a flag of hostility toward the outside world and, most likely, discourage business investment. By a cost-benefit analysis, Alabama is a loser.