University of Vermont

UVM Self-help Web Guide

URLs and Redirects

Your website's primary URL or Web Address

Most UVM zoo accounts (departmental and personal) come pre-configured with a web address or URL based on the account name preceded by a tilde (~), ie: uvm.edu/~anthro. Departmental websites at UVM are usually eligible for a single simple tilde-less web address. Often this address is simply the tilde address without the tilde but a more intuitive name may be chosen. To apply for such an address submit a request for a tilde-less URL to the web team. Any name requests that are not indicative of the sites that they represent, may not be granted. (Personal websites are not eligible for tilde-less addresses.)

Redirects and "friendly" URLs to pages within a website

There are times when you may want to redirect visitors from one URL — or web address — within your website to another. These instances include directing visitors to the "secure" version of a Web page, redirecting visitors from an "old" URL to a new one, or creating a simplified URL — reasons for this might include:

  • you wish to publish the address of a specific page in your website on some print materials
  • you regularly need to direct people on the telephone to a specific page on your website that you don't wish to make publicly available via your home page
  • you want to optimize the link address for search engines

The method for creating such an address depends on the type of redirect. Here are some common scenarios:

Type of redirect Recommended redirect method
Creating a shortcut URL to a page within your site .htaccess
Redirecting visitors to secure pages via HTTPS .htaccess
Redirecting visitors from your old tilde address to your tilde-less one .htaccess
Redirecting an old page to a new page on your site HTTP meta refresh
Redirecting your home page to a new address PHP redirect
Creating a very short link for use on social media sites such as Twitter Link shortening services

.htaccess

This is a useful and powerful method for a variety of redirects including secure redirects and simple URLs. In this method, you will create a text file and save it to your root directory. The filename is .htaccess, note that this file name begins with a "." and has no file extension. You may find it easier to use a command line editor such as Putty (Windows) or Terminal (OSX) when working with this type of file.

There are two basic types of page redirects: 301 is a permanent redirect, and 302 is a temporary one. The structure of the file is quite simple, as you can see in the following example. Note, that you can not only create redirects for web addresses within your website but you can also create redirects to locations not in your site, even outside of UVM.

 Redirect 301 /~mydept/calendar/ http://www.uvm.edu/~mydept/?Page=currcalendar.html&SM=calmenu.html
 Redirect 302 /~mydept/blog/ http://adms.blog.uvm.edu/2008/05/summer_is_coming_are_you.html
 

In the previous example, www.uvm.edu/~mydept/calendar would now go to the longer more unfriendly address. And, if this department had a tilde-less redirect, www.uvm.edu/mydept/calendar would go there too!

If you want to redirect your tilde address to your new tildeless URL, you can also use .htaccess. Example:

 Redirect 301 /~mydept/ http://www.uvm.edu/myaddress
 

If you want to redirect all pages from an old site to a single page on a new site you can use RedirectMatch. Example:

 RedirectMatch 301 .* http://www.uvm.edu/myaddress
 

Creating secure redirects (or redirects to https://) can also be accomplished in your .htaccess file. This example shows how this can be done for an entire directory:

 RewriteEngine On
 RewriteCond %{HTTPS} off
 RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
 

HTTP meta refresh

This method requires no server services and is useful for directing "old" pages to a new URL. If you are moving your website to UVM from a hosted service or server with limited services, this might be a good choice. The following code can be used in an old .html page in your site or in index.html (for a home page redirect) when you wish to redirect visitors to a new location.

 <html>
 <head>
 <meta http-equiv="Refresh"content="0; url=http://www.uvm.edu/~mydept/?Page=newpage.html">
 </head>
 <body>
 <p>This page has moved to <a href="http://www.uvm.edu/~mydept/?Page=newpage.html">here</a>!</p>
 </body>
 </html>
 

PHP redirect

If your site is located on zoo, you can use php to make redirects too. This method is a good choice if your site has changed locations completely. Additionally, if you need to redirect an old php page on your site to another location, this method is preferred over HTTP meta refresh. For example the following code located in an index.php would redirect your home page to a new location.

 <?
 Header("HTTP/1.1 301 Moved Permanently");
 Header("Location:http://www.uvm.edu/newaddress");
 ?>
 

Link shortening services

URL shortening services were initially popular because web addresses started to get long and links would break when sent in an email. However, as microblogging services like Twitter have become popular the need to create short URLs has increased. If you need to create a very short link to any web page for use in email, a QRcode, Twitter or other social media venues, consider using UVM's link shortening service go.uvm.edu.

Last modified March 14 2014 12:28 PM