This is a discussion on Redirect images to a script with htaccess issue. within the Apache Web Server forums, part of the Web Server and Related Forums category; Hi, My site has numerous folders and in each one are images and a php file that reads the folders ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
My site has numerous folders and in each one are images and a php file that reads the folders contents and displays the images as thumbnails and also as individual images when the thumbnails are clicked. If somebody enters a url to one of these images I want them to be sent to the php file which then displays the image. http://www.domain.com/folder/image.jpg to http://www.domain.com/folder/index.php?s=image.jpg So far I have this- RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png)$ [NC] RewriteRule ^(.*)/(.*\.(gif|png|jpg))$ /$1/?s=$2 [R,NC,L] -and although it does the trick, none of the images appear on the webpage. It messes with the image links in the html code. :( I've also tried this- RedirectMatch (.*)/(.*\.(gif|png|jpe?g))$ $1/?s=$2 -but that doesn't seem to work either. Suggestions as to where I'm going wrong? :) I also have code to stop leeching, would this be better placed before or after the image redirect code? Any help would be greatly appreciated as I've turned almost 200 blue google search links purple and still can't get this to work. =) -- Marc :) |
|
|||
|
Hi Marc, On Thu, 24 Jan 2008 16:43:56 GMT, Marc James <vmng@marcjames--remove--.co.uk> wrote: >Hi, > >My site has numerous folders and in each one are images and a php file >that reads the folders contents and displays the images as thumbnails >and also as individual images when the thumbnails are clicked. > >If somebody enters a url to one of these images I want them to be sent >to the php file which then displays the image. > >http://www.domain.com/folder/image.jpg >to >http://www.domain.com/folder/index.php?s=image.jpg > >So far I have this- >RewriteCond %{REQUEST_FILENAME} -f >RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png)$ [NC] >RewriteRule ^(.*)/(.*\.(gif|png|jpg))$ /$1/?s=$2 [R,NC,L] > >-and although it does the trick, none of the images appear on the >webpage. It messes with the image links in the html code. :( > >I've also tried this- >RedirectMatch (.*)/(.*\.(gif|png|jpe?g))$ $1/?s=$2 > >-but that doesn't seem to work either. Suggestions as to where I'm >going wrong? :) > >I also have code to stop leeching, would this be better placed before >or after the image redirect code? > >Any help would be greatly appreciated as I've turned almost 200 blue >google search links purple and still can't get this to work. =) Though it might work with rewrites, I would handle it in PHP, with a database behind it for the mapping of logical names (border-and-pattern.html) which are in $_SERVER['PATH_INFO'] to IDs (lang=0&var1=2-1-1). These articles describe a suitable technique, although it is applied to different problems: http://richardlynch.blogspot.com/200...sposition.html http://www.sitearticles.com/index.ph...rintable&id=18 In your case you could put a php file called folder (without the extension .php !) in your documentRoot and force it to be handled like php using the technique described. You can move the pictures themselves out of the DocumentRoot, so they only can be reached via the script. Of course there are many ways to Rome, I just wanted to show you this one. -- ( Kees ) c[_] An oyster is a fish built like a nut. (#17) |
|
|||
|
On the 24 Jan 2008 in alt.apache.configuration, Kees Nuyt wrote the
following in a hurry. > These articles describe a suitable technique, although it > is applied to different problems: > > http://richardlynch.blogspot.com/200...s-content-disp > osition.html > > http://www.sitearticles.com/index.ph...rintable&id=18 Hi Kees, Thanks for those links, those techniques have got me interested and I'm going to give it a try. :) -- Marc :) |
|
|||
|
"Marc James" <vmng@marcjames--remove--.co.uk> schreef in bericht
news:Xns9A2FAA36D8F49smj12@195.188.240.200... > My site has numerous folders and in each one are images and a php file > that reads the folders contents and displays the images as thumbnails > and also as individual images when the thumbnails are clicked. > > If somebody enters a url to one of these images I want them to be sent > to the php file which then displays the image. > > http://www.domain.com/folder/image.jpg > to > http://www.domain.com/folder/index.php?s=image.jpg > > So far I have this- > RewriteCond %{REQUEST_FILENAME} -f > RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png)$ [NC] > RewriteRule ^(.*)/(.*\.(gif|png|jpg))$ /$1/?s=$2 [R,NC,L] Condition testing extentions is redundant, rule does (about) the same. Keep the redirect -in fact the modified mapping to file- private to the server RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(.*)/(.*\.(gif|png|jpe?g))$ /$1/?s=$2 [NC,L] > -and although it does the trick, none of the images appear on the > webpage. It messes with the image links in the html code. :( The browser will not mess up if not told > I also have code to stop leeching, would this be better placed before > or after the image redirect code? If you want to drop the request, the sooner the better. Rewrites take CPUtime too. HansH |