PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > alt.apache.configuration > Redirect images to a script with htaccess issue.
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
alt.apache.configuration Apache web server configuration issues.

Redirect images to a script with htaccess issue.

Réponse
 
LinkBack Outils de la discussion
Vieux 24/01/2008, 16h43   #1
Marc James
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Redirect images to a script with htaccess issue.

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 would be greatly appreciated as I've turned almost 200 blue
google search links purple and still can't get this to work. =)

--
Marc
  Réponse avec citation
Vieux 24/01/2008, 18h37   #2
Kees Nuyt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Redirect images to a script with htaccess issue.


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 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)
  Réponse avec citation
Vieux 24/01/2008, 20h09   #3
Marc James
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Redirect images to a script with htaccess issue.

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
  Réponse avec citation
Vieux 25/01/2008, 00h54   #4
HansH
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Redirect images to a script with htaccess issue.

"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



  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 18h47.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16460 seconds with 12 queries