Question: How do 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 for any web server running Apache 1.2 or newer)
mkdir command.
mv * command to move all the files and
subdirectories with one command.
| Redirect 301 |
If you want to move the web page from one location on the www.udel.edu server to another location on the same server it is 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.
cd
mkdir
/www/htdocs/engg must exist and you must have write access
to this directory.
mv *
* will expand to all files and
subdirectories in the current working directory.
echo and sed
.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 |
/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.
chmod o+r
.htaccess
file.
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.
| Status | Explanation |
|---|---|
| 301 | Permanent Move
You have no intentions of moving the information back to this location. In fact, at some future date you may want to reuse 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 they see a permanently moved reference. |
| 302 | Temporary Move
You have plans to move the information back so the browser should continue to use the old names. This is the default. |
| 303 | See 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. |
| 410 | Gone
The old location is gone and there is no redirection possible. In this case you must not include a URL in the .htaccess file. |