httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jon Block" <ht...@collegepublisher.com>
Subject RE: [users@httpd] Please help me with this error document directive
Date Fri, 12 Dec 2003 16:42:23 GMT
Hello Robert,

I am still stuck.. here is what I added inside my <virtualhost>.......

 ## Only continue if it is a request that can be handled AND if it doesn't
exist
 RewriteEngine On #turns on mod_rewrite
 RewriteCond %{REQUEST_FILENAME} !-s #checks to make sure file does not
exist
 RewriteCond %{REQUEST_URI}
^.*/news/[0-9]{4}/[0-9]{2}/[0-9]{2}/.+/.+\.shtml$ #checks to make sure the
request matches this pattern
 RewriteRule .* /main.cfm?include=detail [L] # Directs the user to a special
CFM page to handle the missing file.

Here is what I know from my testing so far...

If I request:

http://10.0.0.137/news/2003/02/06/ArtsAndEntertainment/testx.txt

There is no file named testx.txt and I get the default apache 404 error
returned to my browser. That's the desired behavior so thats good.

If I request:

http://10.0.0.137/news/2003/02/06/ArtsAndEntertainment/testx.shtml

I am directed to my "cfm" page. Thats good because the file is not there.

If I request:

http://10.0.0.137/news/2003/02/06/ArtsAndEntertainment/yayForSchool.shtml

I am directed to my "cfm" page. That is *bad* because the shtml file is
actually sitting in the filesystem. Just in case it matters, the path in the
filesystem is
M:\ding\news\2003\02\06\ArtsAndEntertainment\yayForSchool.shtml and the
"/news" in the URL maps to "M:\ding\news". Additionally, the "M:" drive
itself is a virtual drive (created with the subst utility in windows) which
points to "C:\mdrive".

Can you please let me know what it is you think I could be doing wrong? I am
stumped.

Thanks,
Jon


-----Original Message-----
From: Robert Andersson [mailto:robert@profundis.nu]
Sent: Wednesday, December 10, 2003 1:29 AM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Please help me with this error document
directive


Jon Block wrote:
> Here are some URL's that should *not* hit my ErrorDocument directive....
>
> http://www.bbtp.com/news/2003/02/06/ArtsAndEntertainment
> http://www.bbtp.com/news/2003/02/06/ding/
> ...snip...
>
> Here are the url's that *should* hit my error handler
>
> http://www.bbtp.com/news/2003/02/06/yay/iofdios.shtml
> http://www.bbtp.com/news/2003/02/06/bling/doggy.shtml
> ...snip...

Perhaps it doesn't have to be an error document? If I understand your
requirements, this rewrite rule should do it:

    # VirtualHost context assumed
    RewriteEngine On
    # Only continue if it is a request that can be handled
    RewriteCond %{REQUEST_URI} ^/news/([0-9]+/){3}.+/.+\.shtml$
    # and only if it doesn't exist
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* /bling.cfm

I shortened the first pattern so it would fit on a line, but you may expand
it as you had it. You may also want to add the [R] flag to the last rule, so
it performs an external redirect to it. The original request is available in
the environment variable REQUEST_URI, or you could add it to the query
string of bling.cfm if you do an external redirect.

I have not tested it, but I have similar rules that work well. Joshua is the
mod_rewrite guru, so he may give some comments.

Regards,
Robert Andersson


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message