You need to setup it in your .htaccess file, it should looks like this one:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    
    RewriteBase /
    
    RewriteCond %{HTTP_HOST} ^yourdomain\.com$
    RewriteRule (.*) http://www.yourdomain.com$1 [R=301,L]
    
    RewriteRule ^index\.php$ - [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>