Naked domain (also called bare or non-www domain) is a domain name without the preceding www. Non-www domain is usually preferred because it's shorter. However, the www domain is still used for some legacy reason or when required, such as when using a Content Delivery Network or CDN.
Some websites that are available on both www and non-www URL could cause Search Engine Optimisation (SEO) and user experience issues. It is advisable to host your website in any one domain and perform redirection on the other.
A few methods are available to configure such redirection, though cPanel users can configure this from the cPanel dashboard.
Steps to to redirect non-www to www (and vice versa) in cPanel:
- Log in to your cPanel account.
- Click on Redirects from the Domains section.
- Select redirection type from the select list.
This is normally to tell bot visitors such as Googlebot if the redirection is only for temporary or permanent. Naked-to-www redirection or vice versa is normally permanent.
- Select the domain that you want to perform the redirect on from the list.
- Leave the path empty.
This applies the redirect to the whole domain.
- Enter the full URL including http(s) and www in Redirects to field.
Enter the domain without www if you're redirecting www traffic to non-www (bare/naked).
- Select Do Not Redirect www. in www. redirection option.
This is to exclude already-www traffic to also be redirected
Select Only redirect with www. if you're redirecting www traffic to non-www (bare/naked).
- Check on Wild Card Redirect checkbox.
This pass full request path to the target instead of just redirecting to the specified path in Redirects to.
- Click on Add button to apply the changes.
- View generated .htaccess file in your public_html directory.
.htaccess is a hidden file so you'll need to enabe Show Hidden Files (dotfiles) in the File Manager setting to see the file.
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
Comment anonymously. Login not required.