How to redirect a URL?

It may be that you stop offering a service, or that you want to change the structure of your web page, or that you want to change your domain name, for which you now need to make a redirection (or several).

Editorial Team 15 February 2022

When you create your website, everything seems to unfold by itself. You have a very nice page and everything is perfect.
Over time, to your regret, the administration of your page becomes more complex, the things that seemed more comfortable to operate now become complicated.
It is likely that your site has grown and now you need to upgrade your hosting plan, now you have more posts, files, more traffic and URLs, and with it comes chaos.

Having more traffic is great for your website, of course, but creating additional pages, posts and URL structure is not so easy.
It could be that you stop offering some service, or you want to change the structure of your web page, or that you want to change your domain name, for which you now need to make a redirect (or several).

What is a redirect?

Redirecting is pointing one web page or URL to another.
Every time someone enters a URL that they no longer want to use, they are taken to a new page or another address. For example:

URL Redirection
< em>URL redirect examples

There are several types of redirects, and several other ways to do those redirects. Here are the most popular:

Redirect types

301 Redirect

The 301 redirect is the most used. This redirection is permanent, and it is very important because it transfers all the "importance" from one URL to another. Search engines will recognize this redirection and your old URL will disappear, giving priority to the new URL.

301 redirect with PHP

header('HTTP/1.1 301 Moved Permanently'); header('Location:'); exit();

301 redirect with .htaccess

# Redirect the entire website to another domain or URL Redirect 301 /  # You can also do this by specifying your old domain: RewriteEngine on RewriteCond %{HTTP_HOST} ^$ [OR] RewriteCond %{HTTP_HOST} ^$ rewriterule ^(.*)$ [R=301,L]

Redirect http to https

RewriteEngine On RewriteRule ^.well-known/ - [L,NC] RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$$1 [R,L]

302 Redirect

This is a temporary redirect. It is used, for example, when you are setting up a new web page, and you go to a page that says "We are under construction, you will soon be able to access our new page".

# Temporarily redirect the entire website to another domain or URL Redirect 301 /

Meta Refresh Redirect

It is not very popular, but it is very easy to do. Just include the following code inside the <head> of the web page you want to redirect:

<meta http-equiv="Refresh" content="0; url=" />

JavaScript Redirect

It is also very simple, you just have to put the following in the JavaScript to execute:


6 Reasons to do a redirect

1. You changed your domain

If for some reason you had to change your domain, it is necessary to do a redirection from the old domain to the new one.

2. You went from http to https

You purchased an SSL Certificate and now you need your visitors to sign in with https.

3. You have many domains and you want to have only one

You registered multiple domains under your business name, but only want to have one primary domain.

4. You have very long or complicated URLs

If your addresses are of the type, and you want them to be Yes dear friend, you need a redirect.

5. You need to redirect one page to another

If your blog was installed on, but you want it to be

6. You are creating a new web page and don't want visitors to see it yet

Well, we don't have much to say at this point, we already said it all in the title.


You can always use the above methods to perform a redirect. We hope your website grows and improvesimplementing the redirects you learned about in this post.

did you find this article helpful?
Wink Hosting USA