How to fix 200 and 301 redirect

Hello boss
my website host on nginx 14.1 server with ubuntu 18.4 i install ssl letsencypty by Certbot
this way sudo certbot --nginx -d -d
this is my file /etc/nginx/sites-available/

server {

    root /var/www/;
   index index.php index.html index.htm index.nginx-debian.html;
    location / {
            try_files $uri $uri/ /index.php?$args;
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;

            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    location ~ /\.ht {
            deny all;

listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/; # ma$
ssl_certificate_key /etc/letsencrypt/live/; # $
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


server {
if ($host = {
return 301 https://$host$request_uri;
} # managed by Certbot

if ($host = {
return 301 https://$host$request_uri;
} # managed by Certbot

   listen 80 default_server;
    listen [::]:80 default_server;
   return 301$request_uri;
return 404; # managed by Certbot


My website open 2 url look this and
but I want it open like this url please help how to fix
i am not developer Still work plz Show easy way

Hi @mrkumar

please read the output of your domain check -

There is already a sample you may use.

I did not find this code in which file I would look and change
Specify file path

Error - no preferred version www or non-www. Select one version as preferred version, then add a redirect https + not-preferred version to https + preferred version. Perhaps in your port 443 vHost something like "RewriteEngine on" + "RewriteCond %{SERVER_NAME} =" + "ReWriteRule ^{REQUEST_URI} [END,QSA,R=permanent]" (three rows, without the "). That should create a redirect https + ⇒ https + Or switch both values to use the non-www version as your preferred version.

As written. That’s your server. If you use WordPress, you may have to do that in your WordPress configuration.

ok i chack it please wait…

my wp-confi all right but
I do not know how to correct this, change the file from which angle

I don't use WordPress.

But WordPress should have an option to select the preferred version non-www or www.

Selecting that option should add a (system-) correct and search-engine safe redirect.

Mixing raw solutions (explicit server configurations) and solutions from CMS is always critical.

1 Like

It's done i'll be grateful to you

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.