(Kinda) Conditional redirection

New to mod_rewrite? This is a good place to start.

(Kinda) Conditional redirection

Postby Peutch » Sun Nov 28, 2004 2:52 pm

Hi everyone,
I would like to use a special PHP script to display my picture. So I want a redirection like :
/photos/photofile.jpg --> openpic.php?dir=photos&file=photofile.jpg

The problem is, when I try to display the picture on the openpic page, it is of course redirected and thus cannot be displayed (infinite redirection).

My question is, I would like to redirect the images to the Php script, but not when they are displayed on a certain page (the php script). Is that possible ?

I have tried :
Code: Select all
RewriteCond %{SCRIPT_NAME} !/openpic\.php [NC]
RewriteRule the_redirection_rule

but that does not work...
I have also tried to replace SCRIPT_NAME by REQUEST_URI but it does not work either. Any solution ?

Thank you !
Peutch
Peutch
 
Posts: 3
Joined: Sun Nov 28, 2004 2:44 pm

Postby Caterham » Fri Dec 10, 2004 2:42 pm

try
Code: Select all
RewriteEngine On
RewriteRule ^photos/(.+) openpic.php?dir=photos&file=$1 [L]
in a htaccess file in your doc root

Bob
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 9 guests

cron