The issue you often run into trying to use a flashlight that was not designed for use on a rifle is some type of failure with the LED emitter/driver assembly due to shock from the recoil. hmm...I will apologize in advance just in case this gets a little technical and/or flashlight geeky.
If you need what is likely the toughest light on the market, look at Elzetta weapon lights. They don't run off of AA or AAA, however, if it is a weapon light there will likely be quite a bit of on-off use and two CR123a batteries will last quite a while. Also, the CR123A batteries have quite a few advantages over standard AA or AAA. For example, you can buy a 12 pack of CR123A for around $15-$20 on Amazon and put them on the shelf for quite a while. If you don't need them for seven or so years, they will still work (rated shelf life is 10 years, self-discharge rate <1% per year max).
The Elzetta ZFL-M60-SS2A with standard bezel, standard lens, 2-cell body and remote tape switch with 5" cable for $214 is an outstanding light for a rifle.
^you can even select the angle to where it is better for longer range or more of an even flood for closer distances depending on your intended use.
If you want something that is a little less expensive, not quite as bright but still very reliable:
^note: that one is rechargeable.
^If you have never heard of Malkoff Devices, they make very high quality flashlights and drop-in light modules. In fact, the Elzetta flashlights mentioned above use Malkoff Devices drop-ins.
On the other hand, if you do not plan to beat nails into a 2x4 with your tactical light and you do not plan to have it on the weapon every time you go to the range, then you could possibly get by with something considerably less expensive. However, you are running a slight risk that it might fail when you really need it (bad juju if this is a firearm intended for self-defense). With that disclaimer, if I had a limited budget for a weapon light...
I'd buy this flashlight body:
Drop this module into the front of it:
and attach it to a rail with this mount:
~$50 for all three parts and it will run off of two CR123A batteries or a single 18650 rechargeable battery.
If you want to make it rechargeable:
two of these:
and a 18650 battery charger:
That would give you one battery to keep in the light and one spare -- grand total: ~$80.
The nice part about that last option would be the run-times with the 18650 battery. As it is a three mode light, you can get some really extended run-time if you need it. A single 18650 battery would give you:
High setting: 500 lumens for 2 hours
Medium setting: 225 lumens for 4 hours
Low setting: 30 lumens for 35 hours