[WEB4LIB] HTTP 301 Redirect Question
Thomas Dowling
tdowling at ohiolink.edu
Thu Apr 7 10:07:05 EDT 2005
Robert Sullivan wrote:
> I have previously used pages with meta refresh tags when I needed to
> redirect visitors, but impending major changes to our site caused me to
> look at doing it the "real" way. Our site is hosted on a Unix server
> running Apache.
>
> I have most of what I need to do working, and I can redirect from a
> discontinued directory to an error page:
>
> Redirect 301 /directoryname/
> http://www.scpl.org/deadpage.html
>
> What does not work is the case where directoryname has subdirectories;
> the subdirectory (e.g., level 2) name gets appended to the end of the
> error page: http://www.scpl.org/deadpage.htmllevel2
>
> I spent 45 minutes on the phone with the ISP's owner while he tried
> various combinations of regular expressions in my .htaccess file. There
> is probably something simple that we're both missing. Any advice would
> be appreciated.
>
Don't redirect to an error page. If there's a new location for the
page, redirect to that. When you send a 301 status, it doesn't tell the
user agent the page is dead, but that the page has a new location, which
you're supplying. Browsers will update their bookmarks and search
engines will update their indexes, all to point at the target of the
Location header.
You say a page has been discontinued - if deadpage.html is actually an
explanation of why it was discontinued, I'd agree that a 301 redirect
there makes sense. If it's actually a "Page not found" message, I think
you want to handle things with a real 404 status, using this or another
page as your 404 page.
You may want to look at these options:
RedirectMatch permanent ^/dead-directory/
http://www.scpl.org/why-it-is-gone.html
RedirectMatch Permanent ^/dead-directory/(.*)
http://www.scpl.org/find-new-page?old-page=$1
ErrorDocument 404 /explanatory-404-page.html
ErrorDocument 404
/explanatory-script-that-uses-request_uri-variable-to-help-user
--
Thomas Dowling
tdowling at ohiolink.edu
More information about the Web4lib
mailing list