[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] Howto AliasMatch?



> >> That all sounds and looks nice, but it's a lot of work don't you think?
> >> IMO, if you're going to go this far, you might as well let Apache
handle
> >> misspelling errors with mod_speling.  Then you bypass the PHP => SQL
> >> function and everything inbetween.
> >
> >Probably...
> >What were the file you had to convert from and to, in a 'real world
sample?
> >
>
> Can't really show you a real world sample ... as they do not work. The
> pages in question were "cloaked" pages - a page named something.htm that
> was infact a pl script showing one page to regular users and a different
> one to searhc engine spiders. Problem is when I moved from a Raq2 to a
Raq3
> I could not make it accept to run .htm files as cgi.
> Can you have a php page as 404???
> I wanted to do something like you described with a perl script, but a
> 404.cgi (or .pl) is no good...

Here's a XSSI snippet maybe you can use.  Since most all search engines will
index .shtml, this shouldn't hurt your rankings but you may have to resubmit
due to changed document extensions (or simply redirect the .htm(l) version
to the .shtml equivalent server-side.  If you're really paranoid about
rankings or don't wish to resubmit/redirect, you could always turn on SSI
parsing for all .htm(l) docs instead of just .shtml.

This is assuming you're redirecting your 404s to an SSI enabled document:

<!--#if expr="(($REQUEST_URI) && ($HTTP_REFERER)) && (\"$REQUEST_URI\" !=
\"$DOCUMENT_URI\")" -->
  // if we're not called directly or by an "anonymizing" facility //
  <!--#include virtual="my_404_script.php?req_doc=$REQUEST_URI" -->
<!--#else -->
  // if REQUEST_URI is empty (shouldn't be!), show generic 404 //
  <!--#include virtual="my_404_script.php?req_doc=none" -->
<!--#endif -->

(Note that you'll have to remove the lines (// ---- //) before using the
code as SSI provides no facilities for comments that are not passed to the
browser.  You shouldn't output anything to the browser if you plan on doing
a 30x redirect.  This snippet should be 5 lines unwrapped, minus the
comments.)

How it works:

$REQUEST_URI : Document that was asked for
$HTTP_REFERER: Where the request came from
$DOCUMENT_URI: Location of the XSSI script itself

(IF) Checks for existing "$REQUEST_URI" & "$HTTP_REFERER", and also makes
sure they don't eval to the same thing.  If all is well, call your custom
404 script.  I manually passed along the REQUEST_URI via the var $req_doc
since I found that the httpd env vars may not always contain the same value
when eval'd from a another script called via SSI.  Sometimes it will eval to
the calling SSI doc (!). (I tested this with PHP4 and it worked fine w/o
manually passing hardcoded values.  YMMV, testing highly recommended.)

(ELSE) Show a generic 404 page/script.  This should only happen when
someone's using an anonymous browsing tool that removes the HTTP_REFERER, or
the custom_404.shtml is called directly (?).

Try it here: http://www.ctusa.net/custom404/404_custom.shtml

**Note on using XSSI**:
The space before the ending "-->" on each line in the snippet above is
intentional and *necessary* when coding XSSI scripts!  I found that out the
hard way when I learned XSSI - no errors or output to any logs saying that
something is wrong.

HTH

--
Brian Curtis