Complexe redirect
Here goes...
I've just starting working on new sites at my company. I've checking out there servers and WWWOWwww, what a mess. They have multiple sites mixed up in the same directories. My problem now, is to clean that mess up. I want the main site to be seperated from the others. How would this be done. I mean importing the sites to subdirectories is not the problem. But most of these site url were in brochures. Let say that one of my "sub site" has 15 pages. I take it and move it to a subdirectory. When the users type the old URL, they will get the famous 404 error unless I replace the old pages by the blank http-equiv refresh page, which is not what I want to do. Is there a script where you can specify URLs, and as soon as someone tries to access one of those URLs, the script redirects them to the new directory?
If someone understands this, it'll be a miracle.
Please help, and if you don't quite understand, please don't hesitate to ask questions.
Regards,
Luc Deault
----------------------------------
If the minimum wasn't acceptable it wouldn't be called the minimum
-----------------------------------
mairving posted this at 17:14 — 13th July 2001.
They have: 2,256 posts
Joined: Feb 2001
Egads, what a mess. The worst thing about it is that it is print somewhere. I suppose that you could write a custom 404 page with all your redirects on it. A couple of questions though.
What server are you using?
How many pages with redirects are we talking about?
Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states
LukeD posted this at 17:28 — 13th July 2001.
They have: 22 posts
Joined: Sep 2000
approximately 40 pages and we are using Unix
thanks
mairving posted this at 16:36 — 14th July 2001.
They have: 2,256 posts
Joined: Feb 2001
I assume that you are using Apache with that. You could use the Redirect directive in Apache. I am not sure if there is a limit to the number of Redirects that you could use. The redirect can be used in httpd.conf and also in a htaccess file. The htaccess file can give you a bit of a performance hit since it has to reference the file constantly.
What I would do is start with redirecting one link and work on up to the others. Here is Apache's documentation on Redirect:
Redirect directive
Syntax: Redirect [status] url-path url
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Base
Module: mod_alias
Compatibility: The directory and .htaccess context's are only available in versions 1.1 and later. The status argument is only available in Apache 1.2 or later.
The Redirect directive maps an old URL into a new one. The new URL is returned to the client which attempts to fetch it again with the new address. Url-path a (%-decoded) path; any requests for documents beginning with this path will be returned a redirect error to a new (%-encoded) url beginning with url.
Example:
Redirect /service http://foo2.bar.com/service
If the client requests http://myserver/service/foo.txt, it will be told to access http://foo2.bar.com/service/foo.txt instead.
Note: Redirect directives take precedence over Alias and ScriptAlias directives, irrespective of their ordering in the configuration file. Also, Url-path must be an absolute path, not a relative path, even when used with .htaccess files or inside of sections.
If no status argument is given, the redirect will be "temporary" (HTTP status 302). This indicates to the client that the resource has moved temporarily. The status argument can be used to return other HTTP status codes:
permanent
Returns a permanent redirect status (301) indicating that the resource has moved permanently.
temp
Returns a temporary redirect status (302). This is the default.
seeother
Returns a "See Other" status (303) indicating that the resource has been replaced.
gone
Returns a "Gone" status (410) indicating that the resource has been permanently removed. When this status is used the url argument should be omitted.
Other status codes can be returned by giving the numeric status code as the value of status. If the status is between 300 and 399, the url argument must be present, otherwise it must be omitted. Note that the status must be known to the Apache code (see the function send_error_response in http_protocol.c).
Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.