[thelist] Content Negotiation...

Mike King mike.king at redroom.co.uk
Thu Feb 8 10:37:31 CST 2001


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

But if you're using Apache then you can use the mod_negotiation module?
http://httpd.apache.org/docs/content-negotiation.html

Here's what I've whipped up for ASP, it seems to work OK. It takes some 
time to loop through the array on a busy server though... Hmmm, I'll see 
whether I can tweak it up a bit  =)

<%Sub ContentNeg()
   '' take the URL
   ThisURL = Replace(Request.Querystring(), 
"404;http://www.domain-name.org.uk", "")

   FileTypes = Array(".asp", ".pdf", ".gif", ".jpg")

   '' check whether it exists with any extension
          Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
           For i = 0 to UBound(FileTypes)
            If objFSO.FileExists("d:\path\to\public_html" & ThisURL & 
FileTypes(i)) Then
                  Set objFolder = nothing
              Set objFSO = nothing
                  Response.Redirect(ThisURL & FileTypes(i))
        End If
       Next

          Set objFolder = nothing
          Set objFSO = nothing
End Sub%>

Cheers
mk

At 07:54 08/02/01 -0500, you wrote:

>I've thought of the same thing. You can use .htaccess on Apache to 
>redirect 404 errors to a program. That program can then just do
>
>for(qw(html htm shtml gif etc...))      {$redirect = $ENV{'REQUEST_URI'}.$_
>         if -e "$ENV{'REQUEST_URI'}.$_"}

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBOoK2gvoJZSzUdy33EQLAygCeIPX6I6CKN+2tXvsNLGBLkuF6PlQAoKT9
o6a4uHst4V/5AMOVr3yQugyF
=TlTh
-----END PGP SIGNATURE-----





More information about the thelist mailing list