ı have a Canonicalization error. when ı test it in seositecheckup. How can ı resolve this ?
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!
Hi @kocaeli,
Depending on the Web Service you are using - Apache or Nginx the redirection rules are configured differently.
Nginx
If you are using Nginx, you’ll need to add the following block of code in your site’s Nginx configuration
server {
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
DigitalOcean has a pretty good article on how to do that here - https://www.digitalocean.com/community/tutorials/how-to-redirect-www-to-non-www-with-nginx-on-centos-7
Apache
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
I am using
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
You can use this code to redirect the www URL to a non-www URL.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.