Welcome! Log In Create A New Profile

Advanced

non-www to www only

Posted by Ookma-Kyi 
non-www to www only
June 30, 2019 10:05PM
An SEO tool I am using has made this suggestion:

Quote:
Some websites have www in front of their domain, like www.google.com. Others don't, like dribbble.com.

If your website works on the domain www and the one without, you have two identical websites on a different URL. Google will consider that duplicate, and lower your rankings.

There's an easy fix: redirect all your traffic to www. If you have an Apache server, add this to your .htaccess file:

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

However, I am using Nginx and not Apache so that "easy fix" isn't applicable to me. Here is my config file for Nginx:

Link: https://pastebin.com/zsKbtawz

Any assistance would be greatly appreciated.



Edited 1 time(s). Last edit at 06/30/2019 10:13PM by Ookma-Kyi.
Re: non-www to www only
July 01, 2019 03:46AM
Hi Ookma-Kyi,

i think, this question is well known by google. One of the first results is:
https://www.digitalocean.com/community/questions/nginx-https-redirect-www-to-non-www

You should find the answer with this.
Re: non-www to www only
July 01, 2019 04:04AM
Simple,
server_name www.domain.nl domain.nl;

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: non-www to www only
July 01, 2019 09:52PM
NginxModule Wrote:
-------------------------------------------------------
> Hi Ookma-Kyi,
>
> i think, this question is well known by Google. One of the first
> results is:
> https://www.digitalocean.com/community/questions/nginx-https-redirect-
> www-to-non-www
>
> You should find the answer with this.

This isn't working for me. The error I get is:
Nginx: [emerg] "server" directive is not allowed here in /etc/nginx/sites-available/ookma-kyi.tech:1

Config: https://pastebin.com/8Hme7eL1



Edited 1 time(s). Last edit at 07/01/2019 09:52PM by Ookma-Kyi.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 79
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready