Tuesday, July 21, 2015

How do I redirect one Web page URL to another if I have hosting service?

If you have a “domain name only” plan with us, you can redirect your site using our control panel. If you have hosting service with us, you’ll need to do it a little differently, though.

On this page:

Using a “meta refresh”
Using a .htaccess command
Redirecting your entire Web site to a different site entirely
Adding multiple redirects
Using a “301 permanent” redirect

Using a “meta refresh”

One easy way to do it is by adding a meta refresh to the top of an existing page you have, like this:

<meta http-equiv="refresh" content="0; url=http://www.example.org/newpage.html">

Using a .htaccess command

As an alternative, the Apache Web server we use allows you to redirect one URL to another using .htaccess files.

To do this, add the Redirect command to the .htaccess file at the top level of your site. For example, you could add a line like this:

Redirect 302 /index.html /blog/

This line will redirect any request for your home page to the “/blog/” page on the same site. (The “/index.html” will match any request for your home page, overriding any existing default index page in that folder, regardless of its name.)

The new destination URL can omit the host name and begin with a slash, as in the example above, or it can be a full URL. For example, you could use a line like this:

Redirect 302 /folder/oldpage.html http://www.example.org/newpage.html

In this example, whenever someone accesses 

“http://www.example.com/folder/oldpage.html”, their Web browser will take them to “http://www.example.org/newpage.html” instead.

If you use a full URL as the destination, it can be an unrelated Web site, including one that’s not hosted on the Tiger Technologies servers:

Redirect 302 / http://www.example.org/

That line will redirect any URL requested on your site, because the Web server simply checks whether the URL path the visitor requests begins with the text you specify (“/” in this case). All URL paths begin with “/”, so that line matches all of them.

If the visitor’s request includes an additional path as part of the URL, the additional path will be added to the destination. So if the visitor in that last example requests “/about” on your site, they’ll be redirected to “http://www.example.org/about”.

Redirecting your entire Web site to a different site entirely

If you want to redirect every possible page on your entire Web site to the home page of another site, the best .htaccess command is:

RedirectMatch 302 .* http://www.example.org/

This command will redirect all requests for any file on your site over to “http://www.example.org/”. Note that all requests go to the home page of the destination, not the equivalent path. For example, a request for “/about” on your site will be redirected to “http://www.example.org/”, not to “http://www.example.org/about”.

Adding multiple redirects

If you need to create multiple separate redirects, simply add as many separate Redirect lines to your .htaccess file as you need.

For example, if you want to redirect “/about” to one place and “/blog” to another, you could add these two lines to your .htaccess file:

Redirect 302 /about http://www.example.net/our-company-info/
Redirect 302 /blog http://www.example.org/MyNewBlog.html

Using a “301 permanent” redirect

The examples above all use a “302 temporary” redirect. That tells search engines that this redirect might not always happen in the future, and that they should keep checking the original page URL.

If you’re going to permanently stop using the old URL, and you want to make sure that search engines only “know about” the new site, you’d use a “301 permanent” redirect instead. Just change the “302” in the examples to 301, like this:

Redirect 301 /index.html /blog/
Redirect 301 /folder/oldpage.html http://www.example.org/newpage.html
Redirect 301 / http://www.example.org/

RedirectMatch 301 .* http://www.example.org/