Dr Website

How to Redirect Visitors Without Saying 'We've Moved'

Dear Dr. Website®: I recently changed my URL, and I moved my files to the new site and left a page on the old site directing everyone to the new one. I know it's possible to set the page up so it goes straight to the new one automatically. I asked around, looked through countless JavaScript books, and I'm stumped. How do I do it? Two seamless methods for forwarding visitors to your new location involve server redirection and CGI scripting. In either case, you should consult the system administrator or Webmaster at your original service provider for their recommendations.

With server redirection, your Web server software could be configured to redirect all files to a given pathname to a new URL. The exact syntax for this redirect command will differ depending on what kind of server software is used. You can redirect a single file as well as an entire directory. The new path that your files are redirected to must be a full URL, though; partial and relative URLs will not work. Also note that the server must be restarted after editing any configuration files before the redirect will take effect.

It's probably easier to employ this redirect function via CGI scripting, especially if directories or sites hosted by your previous service provider change frequently. You'll need to write or use a CGI program to output a Location header followed by the new URL, according to the following style: Location: http://newsite.com/restofpath/document.html In this case, the new path that your files are redirected to may be either absolute or a pathname relative to your script. Note that you must have two line breaks following this line in your script.

There are a number of CGI resources available online that offer sample redirection scripts, such as the one at Sanford Morton's CGI/Perl Tips, Tricks, and Hints page. The World Wide Web FAQ mentions precautions you can take for older browsers that don't recognize the Location header or expect to see additional header information.

Hassle-Free File Downloads

Dear Dr. Website®: I've been unsuccessful in my attempts to let visitors to my Web site download native CorelDraw documents. I want the browser to prompt users to save the file, but it just spews strange characters to the screen.

In order for your Web server to deliver different kinds of application files to your visitors, you'll first need to ensure that your server is configured to recognize the correct MIME (Multipurpose Internet Mail Extension) type for each type of document, and check that these files end with the right file extension.

When your Web server sends a file to a visitor's browser, it first looks up the extension of the file in a list that maps file extensions to known MIME types. While originally defined as a way to encode file attachments sent via e-mail, MIME has evolved into a general method of indicating the type of any file sent over the Internet.

Your server software comes with a file that lists all the MIME types and file extensions it can recognize. With the NCSA server, this file is named mimes.type; other servers may have different names for this list.

Have your system administrator check the list of recognized MIME types for you. If your application type needs to be added, you must know what file extension and associated MIME type should be input. One resource you may find helpful is the IANA media-types list, which details all MIME types currently registered with the Internet Assigned Numbers Authority.

Someone with root access to your Web server, such as a system administrator, will need to then configure your server appropriately. The server must be restarted any time a server configuration file is updated.

One useful benefit of following these steps to configuring your server to allow users to download application files is that you'll be able to offer content as binary downloads without needing to set up an FTP server first, which could raise a number of security issues for you.



Reprinted from Web Week, Volume 3, Issue 9, April 7, 1997 © internet.com Corporation All rights reserved. Keywords: html Date: 19970407

http://www.internet.com