The most awaited tutorial is here: Learn Installing LEMP


#20

htaccess codes:

# For below redirect rules which do not contains /blog/ in the path
RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$ https://www.example.com/$3

# For blog directory
RedirectMatch 301 ^/blog\/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$ https://www.example.com/$3

# Remove .html from URL Start
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*)\.html$ /$1/ [R=301,L]
# Remove .html from URL End

Tool converted to Nginx:

# nginx configuration

location ~ ^/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$ {
  rewrite ^(.*)$ https://www.example.com/$3 redirect;
}

location ~ ^/blog\/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$ {
  rewrite ^(.*)$ https://www.example.com/$3 redirect;
}

location / {
  if ($request_uri ~ "\.html$"){
    rewrite ^/(.*)\.html$ /$1/ redirect;
  }
}

Is the tool converted correctly?

This doesn’t work, also giving popup redirection.


#21

It appears correctly.


#22

image

This reboot is actually optional/Not needed


#23

Yes… True


#24

how to Migrate a Wordpress to a LEMP? @GulshanKumar


#25

Assuming, you want to migrate an existing WordPress to LEMP Stack. Please check below topics for answers.

As earlier replied for topic Website migration from shared to cloud.


#29

How to enable HTTP/2 on all available sites on the server?


#30

step 9 not clear


#31

Please refer to the example image to understand step 9, how to update DNS records.


#32

You can enable HTTP/2 by changing default port to 443 in each config file. See how https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-with-http-2-support-on-ubuntu-16-04


#33

If I enter any rule in /etc/nginx/sites-available/default, will it apply to all of the server blocks?


#34

not using cloudflare


#35

It’s ok. Assuming you are using domain registrar default nameservers when it will be active you will have options to configure custom DNS records instead of updating nameservers. So, there you can update A, CNAME kind of records.


#36

I have not tried that way. Cannot recommend. :frowning:


#37

@GulshanKumar How to redirect 301 from non www to www in NGINX Server? and where to add the code?

Thanks!
Pramod


#38

WordPress handle www and non-www redirect itself based two things

  1. What URL access while accessing Famous 5-Minute Installation page
  2. What finally exist at WordPress general settings.

#39

OK, Then I don’t need to add the code like this:

server { 
server_name example.com; 
return 301 $scheme://www.example.com$request_uri; 
}

But what to do with these:

Should I add them into Nginx Config which is located in:
/etc/nginx/nginx.conf

or I’ll need to add this into the main server file:
/etc/nginx/sites-available/example-com


#40

This one.

Yes, you don’t need. Usually to prevent from such issue. Make sure always access domain with correct version while Install WordPress. Because WordPress will use same information based on famous 5 minutes installation page.

Source: #32. Visit your blog domain name to setup WordPress for the first time.


#41

I don’t know what will happen if I don’t add these codes. You remember I had 1500 404 errors in search console after adding the codes all problems had been solved. If I will not add them, it will again start happening with my site and site will lose the all link juice from old urls.


#42

One more thing, Is NGINX sufficient and we don’t need to use cache plugin? Asking because as NGINX doesn’t have htaccess and again some codes will require to add into the config file, otherwise cache plugin will not function.