Moving a Web Page

Question: How to I move a web page. I have a web page in a directory with many files and subdirectories. Do I have to change all these files to avoid a "The page you requested was not found on the server" message everytime a web browser uses one of the old names.

Answer:First, consider not moving the resources at all. But if you must here is what you can do from the Unix prompt on copland: (This procedure will also work with on any web server running Apache 1.2 or newer)

  1. Use the cd command to change the current directory to the directory containing all the old web pages files and subdirecties using the cd command.
  2. Create a new directory using the mkdir command, and the full path name of the new directory.
  3. Move all files and subdirectories to this new directory. You can use the mv * command to move all the files and subdirectories with one command.
  4. Put a ".htaccess" file in old directory to tell the web server where the new directory is located and why it was moved.

Redirect command

Every web page on the www.udel.edu server has a "path name". This is used to get to your files from copland and to get the the pages via the web. The file name has "/www/htdocs" appended to the front of the path name and the URL has "http://www.udel.edu" appended to the front of the path name. You can redirect all requests for an old URL with by putting one file in its directory. Put a file named ".htaccess" with the one line:
Redirect 301 Old Path Name New URL
This file must be permitted as any other web document so the www account can read it. With this file in place all URLs coming to the server beginning with the old path name will be redirected to the corresponding page in the new location. It is important that you have the same names and directory structure at the new site. You can remove the files in the old location since they will never be seen.

Example session

If you want to move the web page from one location on the www.udel.edu server to another is is particually simple. Here is an example terminal session where the new directory is created, all the files and directories are moved to the new location, the .htaccess file is put in place to redirect all web users to the new location, and it is permitted so others can read it.
<1>% cd /www/htdocs/engg/DeptsPrgms/RISE <2>% mkdir /www/htdocs/engg/rise <3>% mv * /www/htdocs/engg/rise <4>% echo "Redirect 301 $PWD http://www.udel.edu/engg/rise" \ | sed s#/www/htdocs## >! .htaccess <5>% chmod o+r .htaccess
Here is an explanation of these 4 command:

<1>%cd
This changes current working directory using the full path name of the directory which must exist. This is the directory with the old resources you want to move.
<2>%mkdir
This will make the new directory. The directory /www/htdocs/engg must exist and you must have write access to this directory.
<3>%mv *
This is the move command which will move files and directories to a new directory. The * will expand to all files and subdirectories in the current working directory.
<4>% echo and sed
This is a complicated way to write the correct .htaccess file. If you prefer you can open an editor and put the one line:
Redirect 301 /engg/DeptsPrgms/RISE http://www.udel.edu/engg/rise
The number 301 is the move status which is explained below. The /engg/DeptsPrgms/RISE is the path to the old directory without the root: /www/htdocs, and the URL is the location of the new directory. Notice, this does not have to be on the same server.
<4>%chmod o+r
This changes the mode so the web server can read the .htaccess file.

Move status numbers

The number 301 is the move status. This number tells the browser more details about what to expect in the future from this URL which has been moved.
StatusExplanation
301Permanent Move
You have no intentions of moving the information back to this location. In fact, at some future date you may want to resuse this location for other resources. All users should change their links and bookmarks to this new location. Some browsers automatically change URL in the bookmark list when the see a permenently move reference.

302Temporary Move
You have plans to move the information back so the browser should continue to use the old names. This is the default.

303See Other
The new location has all the old information and maybe more. The new location is not an exact copy of the old and does not have the same title.

410Gone
The old location is gone and there is no redirection possible. In this case you must not include a URL in the .htaccess file.