nGinx is fast becoming one of the most popular web servers around, and it’s no wonder why.,/p>
It’s lightning fast, runs of the tiniest of servers and can handle a tsunami of traffic.,/p>
So what is a website redirect?
It’s simply sends web traffic from one URL to another URL, without the user having to click any links in the middle.
So lets say we want to redirect all traffic going to our old website (lets call it oldsite.com) to our new website (lets call its newsite.com), we would setup a redirect on oldsite.com to send all the traffic automatically to newsite.com
There are two main types of website redirects (in SEO terms).
There is a permanent redirect (commonly called the 301 redirect). This tells the search engines and more modern web browsers that whenever we see this URL automatically treat it as a different URL
So in out example above, if we put a 301 redirect on oldsite.com, the web browsers and search engines would simply substitute oldsite.com with newsite.com and basically act as if oldsite.com does not exists anymore.
A temporary or 302 redirect, says to the web browsers and search engines that the link destination may change, so don’t automatically do a substitution.
Let’s says you have a company blog and you set up a redirect to the latest news article.
So something like companysite.com/latest_news is a redirect to complanysite.com/news/2021-07-03/article.HTML (2021-07-03 is the date of writing). I want this latest_news to send people to the news article, but when a newer article appears, I want it to redirect tp the newer article instead.
So let’s make these redirect using nGinx, using the example given above.
Some where near the start of your conf file in your /etc/nginx/conf.d/ folder, put the following line:
listen 443 ssl http2;
# 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;
So you can see that creating nGinx redirect links is pretty simple and the best part is you don’t have to write any code, install any complicated plugins or mess about with databases.
Simply use the power of nGinx to make your life easier.
Bruce Hearder is a professional front end web developer. Find out more at WebsiteSecrets101.com