How to redirect to ?

ı have a Canonicalization error. when ı test it in seositecheckup. How can ı resolve this ?

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I am using

RewriteEngine On
RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

You can use this code to redirect the www URL to a non-www URL.

Hi @kocaeli,

Depending on the Web Service you are using - Apache or Nginx the redirection rules are configured differently.


If you are using Nginx, you’ll need to add the following block of code in your site’s Nginx configuration

server {
    return 301 $scheme://$request_uri;

DigitalOcean has a pretty good article on how to do that here -


If you are using Apache, the redirection would need to be done in an .htaccess file located in your website’s directory.

You can add the following to the .htaccess file in order for the redirection to work

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

That’s it, you now have examples for both WebServices and you should be good to go!

Regards, KDSys

Do you use Nginx, Apache, or something else?