• Digital accessories
  • Server
  • Digital life
  • Privacy policy
  • Contact us
  1. Home
  2. Article
  3. How to redirect a URL to another URL: 4 methods - Copahost

How to redirect a URL to another URL: 4 methods - Copahost

Rsdaa 18/01/2022 1705

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 to redirect the whole domain (any folder 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 to 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 to a 404 error page.

Method 1: Redirect URL using cPanel

By this method, you need access to 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 to configure the URL redirect in this screen. Firstly, we recommend keeping the field Type as Permanent (301).

Afterward, select the domain name you wish to redirect to 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 to http://www.anotherwebsite.com/.

Click Add, and the URL redirect is done! The source URL will redirect to another URL.

Method 2: Redirect via HTML Meta tag

This is the solution about how to redirect a URL when you have FTP (or similar) access to your site. You just need access to edit the HTML files of the source URL you wish to redirect. Simply edit the specific source HTML file, and add this line to your

section.

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

Old pageThis is the old page that will redirect to the new one

VIDEO

Method 3: Redirect URL using PHP

Now, by this method, you need FTP access to edit files in your server as well. We will create a PHP file named old.php. Here’s how this file will look like:

This way, whenever we access this specific PHP file, the user will be redirected to our destination site.

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

Method 4: Redirect URL using .htaccess

This method consists in editing a file called .htaccess in your server and placing a specific line to make the URL redirection. Please note that the filename .htaccess really contains one “.” on its beginning!

This method requires FTP access to the server so that you can upload files.

Now, edit locally the .htaccess file.

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

First alternative, redirect a specific page called /sourcepage.html to another URL:

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

Second alternative, redirect the whole domain to another URL:

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

And last, redirect one file to another file, locally, in the same domain:

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


PREV: Troubleshooting Active Directory Authentication / AD login ...

NEXT: Troubleshooting - QRemote Error "Could not connect to server ...

Popular Articles

Hot Articles
Back to Top