Wifi problems seem to crop up a lot on here and unfortunately there doesn't seem to be a 'one fix' solution.
However, I have seen that sometimes any one of the following can help some users although, unfortunately, not always. A bit hit and miss I'm afraid - and in no particular order:
- Check wifi security - if it's WEP change it to WPA or WPA2 (preferably, as it's more secure)
- See if using OpenDNS numbers to your network settings as described here helps:http://use.opendns.com/#mac
- Change the wifi channel on the router
- Create a new Network Location: http://support.apple.com/kb/HT5289
- Reboot the router
Also take a look at this link and the links within the article for other ideas:
...and this link:
All the things listed are directed at troubleshooting the iMac, regardless of the fact that other devices connect OK.
There are often threads on here where all devices on a network connect OK apart from the iMac. The suggestions are intended to try and get the Mac behaving the same as everything else on the network.