How to make a redirection from www.domain.tld to domain.tld?

I would like to do the redirection www, but in the cPanel I have not been able to do it, if someone can help me I would appreciate it.

Welcome to the community! Try googling it. You will need to create a .htaccess file in the root htdocs folder of your website

I’ve already tried it, it doesn’t let me create the www subdomain, neither from FTP, nor from the cPanel itself.

To redirect all requests to non-www, add the following lines at the beginning of your website’s .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]

Replace yourdomain.com with your actual domain name.

6 Likes

Try inserting this PHP code in your index.php:

<?php
header("Location: blabla")
?>

The www subdomain is already included in your website, so you don’t need to worry about that. If you want to redirect to non-www then try using the code @SirEpiclyDeveloper sent.

1 Like

remember to change blablabla to your domain