Skip to main content

How to redirect a domain with www prefix to a domain without www?

If you want to redirect, for example, the address https://www.domain.pl to https://domain.pl create a .htaccess file in the main folder with the content:

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

Remember that in the "domains" tab you must have two addresses connected, with www. and without, so for our example www.domain.pl and domain.pl