Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Nginx - Rewrites help.
PostPosted: Wed Apr 27, 2011 8:01 am 
Offline
Senior Newbie

Joined: Mon Dec 13, 2010 6:59 am
Posts: 8
Hello,

I have been scratching my head last 2 days trying to get this working:

I have a Rails application, say, http://example.com and now I want to run a PHP app on http://example.com/coupons

I set up the PHP app but I am having a hard time with nginx rewrites. I hope someone here can assist me:

Here's how I set up things in nginx.conf

Code:

     location /coupons/ {
          alias /home/jjobanputra/code/coupon/upload/;
          index index.php index.html index.htm;
          if (-e $request_filename) {
            expires 30d;
            break;
          }
          rewrite /coupons/(.+)$ /coupons/index.php?q=$1;
        }

        location = /coupons {
          try_files $uri $uri/ @coupons;
        }

        location @coupons {
          include         fastcgi_params;
          fastcgi_pass 127.0.0.1:53217;
          fastcgi_split_path_info ^(/coupons)(/.*)$;
          fastcgi_param SCRIPT_FILENAME /home/jjobanputra/code/coupon/upload/index.php;
          fastcgi_param PATH_INFO $fastcgi_path_info;
        }

        location ~ /coupons/?.*\.php$ {
          if ($fastcgi_script_name ~ /coupons/?(.*)$) {
            set $valid_fastcgi_script_name /$1;
          }
          fastcgi_pass 127.0.0.1:53217;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME /home/jjobanputra/code/coupon/upload/$valid_fastcgi_script_name;
          include /opt/nginx/conf/fastcgi.conf;
        }



Now http://example.com/coupons loads up the home page, however if I try http://example.com/coupons/ (with the extra slash), it says "No input file found"

Same goes with http://example.com/coupons/Admin and so on.. somehow the rewrites are screwed up i guess..

PS: The above code has been tweaked again and again, so if there is something silly, be nice and let me know ;)


Top
   
 Post subject:
PostPosted: Thu Apr 28, 2011 10:54 pm 
Offline
Senior Member

Joined: Sun Feb 21, 2010 5:12 pm
Posts: 64
Yeah. That config is convoluted and flawed. So much so, that I'm not quite sure what it is you're trying to do.

Could you describe what types of files you're serving from the /coupon? How many .php scripts? Are you looking to list directories? Are there actually any index.html files or should everything that isn't an existing static file be passed to index.php?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group