How to redirect a URL to another URL: 4 methods

  • 13,000
  • Tác giả: admin
  • Ngày đăng:
  • Lượt xem: 13
  • Tình trạng: Còn hàng

URL redirection is widely used for several reasons. There are many tools that help us make a simple and effective URL redirect. In this article, we will show some examples. If you wish đồ sộ redirect the whole tên miền (any thư mục and page on it), then we recommend this article.

For SEO purposes, we always recommend using 301 Redirects (Permanent).

What is an URL Redirect

That means that when the visitor comes into the source (old) URL, it will be transferred automatically đồ sộ the destination (new) URL.

There are basically two types of redirection: temporary (302) and permanent (301). Google values much more pages with permanent ones (301 Redirects), as per Matt Cuts. As a conclusion, we recommend using 301 Redirects whenever possible. Make sure you place the correct destination URL. Otherwise, you can lead đồ sộ a 404 error page.

Method 1: Redirect URL using cPanel

By this method, you need access đồ sộ your cPanel control panel. This is maybe the easiest and fastest method.

Firstly, access your cPanel control panel. Scroll down and find the Domains – Redirects icon, as shown in the photo. Then, click on it.

Then, we will explain how đồ sộ configure the URL redirect in this screen. Firstly, we recommend keeping the field Type as Permanent (301).

Afterward, select the tên miền name you wish đồ sộ redirect đồ sộ outside. For instance, http://mysamplewebsite.com/specificpage.html is our source URL.

Under Redirects to, place the details of the destination URL. For example, we will redirect đồ sộ http://www.anotherwebsite.com/.

Click Add, and the URL redirect is done! The source URL will redirect đồ sộ another URL.

How đồ sộ redirect a URL

Method 2: Redirect via HTML Meta tag

This is the solution about how đồ sộ redirect a URL when you have FTP (or similar) access đồ sộ your site. You just need access đồ sộ edit the HTML files of the source URL you wish đồ sộ redirect. Simply edit the specific source HTML tệp tin, and add this line đồ sộ your section.

For example, here’s how the HTML will look like:




Old page


This is the old page that will redirect đồ sộ the new one

Method 3: Redirect URL using PHP

Now, by this method, you need FTP access đồ sộ edit files in your server as well. We will create a PHP tệp tin named old.php. Here’s how this tệp tin will look like:

This way, whenever we access this specific PHP tệp tin, the user will be redirected đồ sộ our destination site.

We can also use a more complete PHP tệp tin, specifying that this is a 301 redirect (permanent). In this case, the PHP tệp tin would look like:

Method 4: Redirect URL using .htaccess

This method consists in editing a tệp tin called .htaccess in your server and placing a specific line đồ sộ make the URL redirection. Please note that the filename .htaccess really contains one “.” on its beginning!

This method requires FTP access đồ sộ the server so sánh that you can upload files.

Now, edit locally the .htaccess tệp tin.

You can choose one of the following code options. We will explain each one:

First alternative, redirect a specific page called /sourcepage.html đồ sộ another URL:

Redirect 301 /sourcepage.html http://www.mynewdomain.com/

Second alternative, redirect the whole tên miền đồ sộ another URL:

Redirect 301 / http://www.mynewdomain.com/

And last, redirect one tệp tin đồ sộ another tệp tin, locally, in the same domain:

Redirect 301 /old/path/oldpage.html http://www.currentdomain.com/new/path/newpage.html