Redirect www to non-www in cPanel
Setting up a proper redirection for your website is crucial for both user experience and search engine optimization (SEO). One of the most common scenarios is deciding whether your site should be accessible with or without the 'www' prefix. For most modern websites, the trend is to opt for the non-'www' version (often called "root domain" or "naked domain"). In this guide, we will show you how to set up a permanent 301 redirect from www to non-www using cPanel tools, the management interface that PlatiniumHost offers for its hosting services.
Why redirect www to non-www?
- Consistency: Ensures your site is accessible via a single canonical URL, simplifying branding and memorization for users.
- Improved SEO: Avoids duplicate content issues in the eyes of search engines, consolidating your domain's authority into a single version and improving its visibility.
- Aesthetics and User Experience: Provides a shorter, cleaner URL, which is often preferred by users and makes sharing links easier.
There are two main methods to achieve this redirection in cPanel. We will explain both, so you can choose the one that best suits your needs or comfort level with managing your PlatiniumHost hosting.
Method 1: Using cPanel's 'Redirects' tool
This is the simplest and recommended method for most users, as it does not require direct file editing and is managed by cPanel's intuitive interface.
- Access your cPanel: Log in to your cPanel account through the PlatiniumHost client area or directly using the credentials provided by your provider.
- Locate the 'Redirects' section: In the main cPanel panel, find the 'Domains' section and click on 'Redirects'.
- Configure the redirection:
- On the 'Redirects' page, ensure that the 'Type' of redirection is 'Permanent (301)'.
- In the 'http://(www.)?' field, select the domain with 'www' that you want to redirect (e.g.,
www.yourdomain.com). - In the 'Redirects to' field, enter the full URL of your domain without 'www' (e.g.,
https://yourdomain.comorhttp://yourdomain.com, depending on whether your site uses SSL/HTTPS). It is crucial to includehttp://orhttps://for the destination URL. - Ensure that the 'Redirect with or without www.' option is set to 'Redirect only with www.'.
- Check the 'Wildcard Redirect' box if you want all subpages of
www.yourdomain.com/pageto redirect correctly toyourdomain.com/page. This is highly recommended to maintain link structure. - Finally, click the 'Add' button to create the redirection.
https:// to avoid security warnings or redirection loops.Method 2: Editing the .htaccess file
This method is more advanced and requires directly editing your website's .htaccess file. Use this method if you need more granular control, if the previous method doesn't work for some reason, or if you prefer to manage your redirects at the server level.
- Access your cPanel: Log in to your Pl cPanel account