Do you have a quote as to what section says people under 18 or 21 cannot own/carry rifles? A search for '18' and '21' came up with a few 'illegal to transfer a weapon that can be concealed to someone under 18' and the like, but also a section saying:
> (c) Nothing in paragraph (1) of subsection (a) of this Section prohibits a person under 18 years of age from participating in any lawful recreational activity with a firearm such as, but not limited to, practice shooting at targets upon established public or private target ranges or hunting, trapping, or fishing in accordance with the Wildlife Code or the Fish and Aquatic Life Code.
which implies there are at least some situations in which it is legal for a 17 year old to possess and possibly transport a rifle.
EDIT: Here's a summary I just found:
> Minimum Age to Purchase & Possess in Illinois
> Illinois prohibits any person under age 18 from possessing a handgun. State law also prohibits any person from knowingly transferring a handgun to any person under age 18. However, Illinois also prohibits any person from knowingly transferring a firearm to any person who does not hold a FOID card. To obtain a FOID card, an individual must be over 21 years of age or have the written consent of his or her parent or legal guardian to possess and acquire any firearms and ammunition. Further, the parent or legal guardian must not be prohibited from obtaining a FOID card. Persons under age 21 also do not qualify for a FOID card if they have been convicted of a misdemeanor (other than a traffic offense) or adjudged delinquent.
from https://www.ichv.org/legislation/illinois-state-gun-laws/
Which says Illinois prohibits minors from owning pistols, but also says if they have the appropriate FOID card then they can own things-other-than-pistols.