The most awaited tutorial is here: Learn Installing LEMP


htaccess codes:

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

# For blog directory
RedirectMatch 301 ^/blog\/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$$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 ^(.*)$$3 redirect;

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

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

Is the tool converted correctly?

This doesn’t work, also giving popup redirection.


It appears correctly.



This reboot is actually optional/Not needed


Yes… True


how to Migrate a Wordpress to a LEMP? @GulshanKumar


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.


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


step 9 not clear


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


You can enable HTTP/2 by changing default port to 443 in each config file. See how


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


not using cloudflare


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.


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


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



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.


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

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

But what to do with these:

Should I add them into Nginx Config which is located in:

or I’ll need to add this into the main server file:


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.


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.


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.