در htaccess کد زیر رو قرار بدین
- - - Updated - - -کد HTML:location / { if ($http_host ~ "^example.com$"){ rewrite ^(.*)$ http://www.example.com$1 redirect; } }
سیستم عامل هم بخواید
اگر سنتوس باشید
etc/nginx/conf.d/redirect.conf
کد PHP:
server {
server_name example.com;
return 301 $scheme://www.example.com$request_uri;
}