Is there a way to redirect all the pages, which are written without the www. to the same page with www.

http://XXXX.com/page1.html redirects to http://www.XXXX.com/page1.html
http://XXXX.com/page2.html redirects to http://www.XXXX.com/page2.html
http://XXXX.com/page3.html redirects to http://www.XXXX.com/page3.html
http://XXXX.com/page4.html redirects to http://www.XXXX.com/page4.html
http://XXXX.com/page5.html redirects to http://www.XXXX.com/page5.html
http://XXXX.com/page6.html redirects to http://www.XXXX.com/page6.html

I added in my Cpanel a permanent redirect:
http://XXXX.com/ redirects to http://www.XXXX.com/
But it only works for the main domain and not the pages inside it

If anyone knows how to do that, I will be really happy to learn how this could be done