Welcome! Log In Create A New Profile

Advanced

rewrite for php script

Posted by fwarren 
rewrite for php script
January 30, 2012 01:45PM
I have a script named gallery.php the behaviour I am looking for is the following

url: http://mysite.com/images/gallery/sample.jpg
rewrite: http://mysite.com/images/gallery/gallery.php?src=sample&thumb=

url: http://mysite.com/images/gallery/thumb/sample.jpg
rewrite: http://mysite.com/images/gallery.php?src=sample&thumb=thumb

So the gallery.php script when called with thumb=thumb will return the jpg resized to 30x10, and when called without the thumb will retrun the image reszied to 600x200.

The apache rewrite rule is

rewrite ^(thumb/)?(.*)\.jpg$ gallery.php?src=$2&thumb=$1


I think I am on the right track what I have tried to do with nginx is the folllowing:

location ~^/gallery/thumb/(.*)\.jpg$ {
fastcgi_pass unix:/tmp/fastcgi.sock;
fastcgi_param SCRIPT_FILENAME /var/www/testalmar/httpdocs/images/gallery/gallery.php;
fastcgi_param QUERY_STRING src=$1&thumb=thumb;
}

location ~^/gallery/(.*)\.jpg$ {
fastcgi_pass unix:/tmp/fastcgi.sock;
fastcgi_param SCRIPT_FILENAME /var/www/testalmar/httpdocs/images/gallery/gallery.php;
fastcgi_param QUERY_STRING src=$1;
}

Which is not working. I am still missing something. Any suggestions on how to rewrite this?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 327
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready