Apache Server configuration support - mod_rewrite recursion question

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > January 2007 > mod_rewrite recursion question





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author mod_rewrite recursion question
Mark

2007-01-06, 8:11 pm

Good morning

I am setting up a directory to serve image files. I want requests made
to this directory to be redirected to a CGI script. The CGI script would
return a simple web page containing a linked image. So this request:

http://www.foo.com/image/some_image.jpg

Would return a web page that contains an image tag:

<img src='http://www.foo.com/image/some_image.jpg'>


The problem of course is that when the browser processes the image
tag and requests the image, it encounters the same mod_rewrite handling.

Any suggestions? All I can think of is to have my CGI script copy the
image into a subdirectory and source the image tag from there, but I am
hoping for something a bit more elegant.

Thanks
-Mark


Mark

2007-01-06, 8:11 pm

Oops...I forgot to mention that the rewrite rules will be set up
in an .htaccess file. I do not have access to the server configs.


Davide Bianchi

2007-01-06, 8:11 pm

On 2006-12-28, Mark <anon40629@hotmail.com> wrote:
> Any suggestions?


What are you trying to accomplish this way?
Davide

--
From the moment I picked your book up until I laid it down I was
convulsed with laughter. Someday I intend reading it.
-- Julius Henry "Groucho" Marx (http://en.wikiquote.org/wiki/Groucho_Marx)
Mark

2007-01-06, 8:11 pm

"Davide Bianchi" <davideyeahsure@onlyforfun.net> wrote:
> On 2006-12-28, Mark <anon40629@hotmail.com> wrote:
>
> What are you trying to accomplish this way?
> Davide


If the user requests an image from my server,
I want to return a 'text/html' stream with an IMG
tag referencing the requested image.

The default behavior would be to return a 'image/jpeg',
'image/gif', etc.

Hmm. . .I suppose I could do it this way:

/image
Empty directory with rewrite rule invoking a CGI script
whenever an image MIME type is requested. The requested
image must actually exist in the /image/binaries
subdirectory

/image/binaries
Subdirectory containing the actual image files.
The CGI script invoked from the parent directory will
return an HTML document containing an IMG tag whose
SRC attribute points to the image file in this subdir.



Mark

2007-01-06, 8:11 pm

"Mark" <anon40629@hotmail.com> wrote:
>
> Hmm. . .I suppose I could do it this way:
>
> /image
> Empty directory with rewrite rule invoking a CGI script
> whenever an image MIME type is requested. The requested
> image must actually exist in the /image/binaries
> subdirectory
>
> /image/binaries
> Subdirectory containing the actual image files.
> The CGI script invoked from the parent directory will
> return an HTML document containing an IMG tag whose
> SRC attribute points to the image file in this subdir.


Ok, that did the trick. I also had to put a "RewriteEngine off"
directive in the /binaries subdirectory.

This still seems a bid kludgey, so I am interested in any cleaner
alternatives that anyone can propose.

-Mark


Mark

2007-01-06, 8:11 pm

"HansH" <hansh@invalid.invalid> wrote:
> WHY are you making this fuzz, a browser can show the image without the
> HTMLwrap too.


I guess I'm just a fuzzy guy. :-)



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com