Category: Redirect

Redirecting a Web page or site with .htaccess

This help page explains how to redirect a single web page, a directory of web pages, or an entire website to a new web address, using the .htaccess method.

See Cruzio’s redirect overview to decide which redirect method you should use.

Please proceed with caution. If you make mistakes, your website may become unreachable.

What is a .htaccess redirect, and why should I use it?

With the .htaccess (pronounced “dot-aitch-tee-access”) redirect method, also known as a “301 redirect,” you create a special configuration file on your site containing a redirect “directive” (instruction to the web server).

When someone visits the redirected web address, the web server will obey your directive and automatically redirect them to the new address.

Benefits of a .htaccess redirect:

  • Automatically redirects links and bookmarks to a web page at its old address to the new address
  • Preserves search engine rankings (such as Google PageRank) for the redirected web page
  • Lets you create multiple redirects in the same place

» back to top

Redirecting a single web page

  1. Log in to your web space, using either an FTP program (such as Filezilla or CyberDuck) or your website’s File Manager.  (Note: if you have Cruzio Classic hosting, the File Manager is not available, and you must use FTP instead.)  If you are using an FTP program, make sure it is set to view hidden files. (Otherwise, any file starting with a dot, such as the file we are about to create, will be hidden from view.)In the File Manager or your FTP program, go to the root directory (the folder containing your website files) of your website.
    Type of web hosting Name of root directory
    Website Hosting httpdocs
    Classic pub_html

     

  2. In the root directory, look for a file named .htaccess (including the dot at the beginning).If you do not already have a .htaccess file in the root directory, create a file there named .htaccess including the dot at the beginning, and with no file extension at the end.Note: if you create or copy a file named .htaccess on your computer’s hard drive, you may not be able to see the file. Files beginning with a dot are typically hidden from view. Instead, if you need to work with a file on your hard drive, name it htaccess (without the dot, and without any extension). You can rename it to .htaccess after you upload it to your web space.
  3. Open the .htaccess file for editing.To create a redirect, add the following code anywhere in the file:
    RewriteEngine On
    Redirect 301 /pathto/oldpage.extension http://yourdomain/pathto/newpage.extension
    

     

    In the code, make these changes:

    For this: Substitute this:
    pathto the path to the directory containing the page
    (for example, “produce/fruit/apples”)
    oldpage the filename of the page you are redirecting
    extension the page’s extension, if it has one
    (for example, “html” or “php”)
    yourdomain the page’s domain at the new address, even if you’re not changing the domain
    (for example, “joesfreshproduce.com”)
    newpage the filename of the new page

     

    Notice that you start the old address with only a slash “/”, with no domain. Start the new address with “http://”.

    Save the changes to your .htaccess file.

    If the file is not already in the root directory of your website, upload it there. Then, if the filename is not .htaccess, including the dot, change the filename. If there is an extension (like .txt) at the end, remove it.

  4. To view the redirect, enter the old address into the address bar of your web browser. If it does not forward right away, click the refresh button of your web browser and it should update.

Your permanent web page redirect is active!

The next time a search engine visits your site, it will update its records with the page’s new address, while preserving the page’s search rankings.

What if I only need a temporary redirect?

To create only a temporary redirect, use “Redirect 302” instead of “Redirect 301” in your .htaccess code.

» back to top

Redirecting a section of your website

We will use the .htaccess method to redirect a section (usually called a directory) of your site.

Follow the instructions for redirecting a single page, but use code like this in your .htaccess file:

RewriteEngine On
Redirect 301 /pathto/olddirectory/ http://yourdomain/pathto/newdirectory/

Note: if you redirect to a directory that does not contain an index file, you may get a 403 Forbidden error. In this case, either create an index file in the destination directory, or add this line to your .htaccess file to turn on auto-indexing:

Options +Indexes

» back to top

Redirecting your entire website to another website

We will use the .htaccess method to redirect your entire website to another site.

Follow the instructions for redirecting a single page, but use code like this in your .htaccess file:

RewriteEngine On
Redirect 301 / http://newdomain/

Make sure you include a space before and after that first lone slash.

» back to top

Redirect example: Joe’s Fresh Produce

Joe sells produce on his site, joesfreshproduce.com. He has a web page he uses to sell his tomatoes. He used to have the page in the fruit area of his site, but his site visitors missed it, because they were looking for tomatoes in the vegetables instead.

Joe decided to move the tomato page. He moved the file tomatoes.html from the fruit directory to the vegetables directory.

Joe wanted people looking for the page at its old address to find it at the new one, so he decided to create a redirect. He added this redirect code to the .htaccess file on his site, joesfreshproduce.com:

RewriteEngine On
Redirect 301 /fruit/tomatoes.html http://joesfreshproduce.com/vegetables/tomatoes.html

 

More shoppers are finding Joe’s tomatoes now. The long-time customers who had bookmarked the old tomato page are automatically redirected to the new page. Links from other sites to the old tomato page automatically go to the new page. Joe’s tomato sales are up!

» back to top

Redirecting a web page with meta refresh

This help page explains how to redirect a single web page to a new web address, using the meta refresh method.

See Cruzio’s redirect overview to decide which redirect method you should use.

Please proceed with caution. If you make mistakes, your website may become unreachable.

What is a meta refresh redirect, and why should I use it?

With the meta refresh redirect method, you put some specific HTML code in your old web page.

When someone visits the old page, the redirect will automatically take them to the new address.

Benefits and drawbacks of a meta refresh redirect:

  • Does not require access to your website’s root directory
  • Requires that you access and edit each page that you want to redirect
  • Does not preserve search engine rankings or inbound links for the redirected page
  • Because spammers use this technique, search engines may penalize the page’s rank

A meta refresh redirect is not as good as a .htaccess redirect, which is more powerful and preserves search engine page rankings. However, sometimes only a meta refresh redirect is possible. For example, if you are moving from a free GeoCities site to Cruzio hosting, Yahoo! does not allow you to use a .htaccess redirect. A meta refresh redirect, done properly, is the right method in this case.

» back to top

Redirecting a page with meta refresh

  1. Log in to your Web space, using either an FTP Program (such as Filezilla or CyberDuck) or your website’s File Manager. (Note: if you have Cruzio Classic hosting, the File Manager is not available, and you must use FTP instead.)

    In your Web space, find the page you want to redirect.

  2. Open the page’s file for editing.

    Remove all existing code from the page. To replace it, paste in the following code:

    <html>
    <head>
    <title>Moved to new address: http://yourdomain/pathto/newpage.extension</title>
    <meta http-equiv=refresh content="0; url=http://yourdomain/pathto/newpage.extension" />
    <meta name="robots" content="noindex,follow" />
    </head>
    <body>
    <h1>This page has been moved to http://yourdomain/pathto/newpage.extension</h1>
    <p>If your browser doesn't redirect you to the new location, please <a href="http://yourdomain/pathto/newpage.extension"><b>click here</b></a>. Sorry for the inconvenience!</p>
    </body>
    </html>
    

     

    Note: it’s important that you do not add any keywords or advertising to this page, and that you do not delay the refresh by changing the number 0. If you do these things, you risk having your page be regarded as Web spam, and being penalized by search engines.

  3. In the new code, make these changes:
    For this: Substitute this:
    yourdomain the page’s domain at the new address
    (for example, “joeswebsite.com”)
    pathto the path to the directory containing the page
    (for example, “topics/news”)
    oldpage the filename of the page you are redirecting
    (include only a slash “/” in front of oldpage, creating a “relative address”)
    extension the page’s extension, if it has one
    (for example, “html” or “php”)
    newpage the filename of the new page
    (include the initial “http://” in front of newpage, creating an “absolute address”)

     

    Save the changes to your page.

    Your redirect is active! Test it by opening the old page in your browser, and making sure the browser takes you to the new location.

» back to top

Redirecting a website or web page: Overview

This help page is an overview of different methods for redirecting a website or web page, and the situations where each method is preferred.

Please proceed with caution. If you make mistakes, your website may become unreachable.

Redirect Methods

  • .htaccess

    A .htaccess (pronounced dot-aitch-tee-access) redirect is powerful, flexible, and preserves your search engine page ranking. In most cases, you should use this method.

  • Forwarding or an A Record

    Forwarding is a very good and easy redirect method if you just bought an extra domain name, and want to point it to an existing website.

    Redirecting with an A record has limitations, but can be used in some cases. In cases where an A record will not work, you can use the .htaccess method instead.

    Both of these methods can redirect entire websites, but not individual pages.

  • Meta Refresh

    A meta refresh redirect is not as good as a .htaccess redirect. However, some web hosts may not allow you to use a .htaccess file. In that case, use a meta refresh.

    A meta refresh can only redirect a single web page at a time.

Redirecting a website using Forwarding or an A Record

This article explains how to redirect an entire website to another website.

These instructions apply only to Cruzio Website Hosting services. If you have Cruzio’s Classic hosting, contact Cruzio to request a change to your A Record, or use a .htaccess redirect instead.

See Cruzio’s redirect overview to decide which redirect method you should use.

Please proceed with caution. If you make mistakes, your website may become unreachable.

Two methods; which should you choose?

If you have an extra domain and you simply want to point it to an existing website, then Standard or Frame Forwarding is the easiest way to do that.

Maybe you need to temporarily redirect a domain that already has a website on it, without destroying those website files. In this case, you may modify your A Record if you can. However, please note the limitations of this method in the A Record section below. You may want to use the .htaccess method instead, as it works in cases where an A Record will not.

» back to top

Redirecting with Standard or Frame Forwarding

To redirect a domain name to a website hosted on another domain:

  1. Login to your domain control panel at http://login.cruzio.com.
  2. In your Control Panel, look under Main Menu for the Domains section of your Home page. If you are on Host 6 or above, you will need to first click “Domains” under the Main Menu in the upper left hand corner. If the domain you want to redirect was previously set up for hosting, you will need to remove it. Back up any site files you want to keep, then remove that domain.

    If you do not know what Host number you are on, after you log into your control panel, look at the URL at the top of your browser. You will see it start with ‘https://host’ followed by a number. That is the Host number you are on.

  3. If you are on Host 1, 2, 3, 4, or 5, click the “Add New Domain” icon in the Tools section. Type in the domain name that you want to redirect. Leave the “www” check box selected. Leave the “Create domain without template” option selected. Make sure “Proceed to hosting setup” is checked. Click “OK”.

    If you are on Host 6 or above, click the “Create Domain icon” in the Tools section. Type in the domain name that you want to redirect. Leave the “www” check box selected. Change “Use domain template settings” to “Default Domain”.

  4. For Host 1, 2, 3, 4, or 5, choose either “Standard forwarding” or “Frame forwarding”, then click “OK”.

    For Host 6 or above, select “Forwarding” under Hosting Type. Then under “Forwarding Settings”, choose either “Standard forwarding” or “Frame forwarding”.

    With standard forwarding, a visitor is redirected to the site and the actual site’s URL is shown in the visitor’s browser, so the visitor always knows they were redirected to another URL.

    With frame forwarding, a visitor is redirected to the site without knowing that the site actually resides at another location.

  5. Specify the Destination URL: the website address that you would like this domain to point to. Click “OK” or “Finish”.
  6. To test the forwarding, enter the address of the forwarded domain into the address bar of your web browser. Your browser should take you to the destination URL.

» back to top

Redirecting with an A Record

Using an A Record as a method to redirect a website has serious limitations. Rather than redirecting to a different website, per se, you are redirecting to an IP address. If more than one website is at that IP address, you cannot control which website the redirect will go to.

To see which website a particular IP address will go to, simply enter that IP address in your browser’s address bar.

To redirect a website to another IP address:

  1. Login to your domain control panel at http://login.cruzio.com.
  2. On your Home page, click on the domain name of the website you would like to redirect. If you are on Host 6 or above, this can be accessed by first clicking “Domains” under the Main Menu in the upper left hand corner.
  3. For Host 1, 2, 3, 4, or 5, click “DNS Settings” under the Services section.

    For Host 6 or above, click “DNS Settings” under the Web Site section.

  4. There should be, among the other A records, an A record of the form:
    Host		Record Type	Value
    yourdomain.com	A		IP.address
    

    Where:

    • yourdomain.com is the name of your domain; and
    • IP.address is the IP address of the domain.
  5. Click the host name in this record.

    Leave the “Record type” menu set to “A”.

    Leave the box labeled “Enter domain name” blank.

    In the box labeled “Enter IP address *”, enter the IP address you are redirecting to.

    Click “OK”.

Note: Your new A record will take up to 24–48 hours to take effect. This is because a new A record is a DNS change, and all DNS servers worldwide need to be updated to reflect the change. To test whether the A Record has taken effect, enter the address of the redirected domain into the address bar of your web browser. If the record has taken effect, your browser will take you to the website at the destination IP address.

» back to top