July 26th, 2001, 10:58 AM
Our web site domain has recently changed from mydomain1.com to mydomain2.com. However, there are still urls floating around out there from search engine bots etc. that include mydomain1.com, making a lot of broken links. Any url on the site must use the new mydomain2.com because of a Perl script that basically runs the site.
My question: Is there a way to configure Apache so that any request for mydomain1.com is automatically changed to mydomain2.com? This would include longer URLS like mydomain1.com/images/myimage.jpg which would be automatically changed to mydomain2.com/images/myimage.jpg
Any help would be greatly appreciated.
July 30th, 2001, 04:10 PM
This fit the bill? Yanked from apache.org
Syntax: Redirect [status] url-path url
Context: server config, virtual host, directory, .htaccess
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.
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 <Directory> 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:
Returns a permanent redirect status (301) indicating that the resource has moved permanently.
Returns a temporary redirect status (302). This is the default.
Returns a "See Other" status (303) indicating that the resource has been replaced.
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).
July 30th, 2001, 04:53 PM
That's exactly what I was looking for!
July 31st, 2001, 11:12 AM
Glad I could help ^_^