How to Perform Website Redirects Using NGinx - nginx redirect http to https

How to Perform Website Redirects Using NGinx – nginx redirect http to https

How to Perform Website Redirects Using NGinx – nginx redirect http to https – It should come as no surprise that nGinx is rapidly climbing the ranks to become one of the most widely used web servers available.

/p>

It processes at the speed of light, can operate on the most modest of servers, and is able to deal with an overwhelming volume of traffic.

/p>

In that case, what exactly is a website redirect?

Web traffic is simply redirected from one URL to another URL, and the user is not required to click on any links that are presented to them along the way.

If we wanted to send all of the traffic that was going to our old website (let’s call it oldsite.com) to our new website (let’s call it newsite.com), we would have to set up a redirect on oldsite.com so that it would send all of the traffic automatically to newsite.com. So, let’s say that we want to redirect all of the traffic that was going to oldsite.com to newsite.com.

There are primarily two kinds of redirects used on websites (in SEO terms).

There is a redirect that will always be there (commonly called the 301 redirects). This indicates to the search engines and web browsers that are more up-to-date that whenever we come across this URL, we should automatically treat it as if it were a different URL.

If we were to implement a 301 redirect on oldsite.com, then the web browsers and search engines would replace oldsite.com with newsite.com and essentially behave as if oldsite.com no longer exists. This is because a 301 redirect is a permanent redirection.

A temporary redirect, also known as a 302 redirect, indicates to web browsers and search engines that the link destination may change in the future; as a result, they should not perform an automatic substitution.

Let’s say you run a business and maintain a blog; suppose also that you regularly update it with the most recent company news.

If you go to companysite.com/latest news, for example, you will be redirected to companysite.com/news/2021-07-03/article.HTML (2021-07-03 is the date of writing). I want people to go to the news article when they click on this latest news link, but if a more recent article is published, I want it to redirect to the more recent article instead.

Therefore, let’s make these redirects using nGinx, using the earlier provided example as a guide.

Put the following line somewhere near the beginning of your configuration file in the conf.d folder of your /etc/nginx directory:

# This will create a 302 link rewrite /latest news$ /news/2021-07-03/article.HTML redirect; # This will create a 301 link rewrite /latest news$ /news/2021-07-03/article.HTML permanent;… server listen 443 ssl http2; server name companysite.com; root /website; index index.HTML; ssl

As you can see, the process of creating nGinx redirect links is quite straightforward, and the best part is that you don’t need to write any code, install any complicated plugins, or fiddle around with databases.

Make your life simpler by putting the power of nGinx to work for you.

Advertisement

Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *