Forum: NGINX rewrite rule from apache

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
matt91 (Guest)
on 2009-06-02 03:09
(Received via mailing list)
I'm new to nginx. I've got it all set up apart from a few rewrite rules
I need to add from apache, these are:

RewriteRule ^bg_sound_([^_]*)\.xspf$
/includes/bg_audio_player/bg_sound.php?tributeid=$1
RewriteRule ^elvis$ tributeindex.php?artiste=elvis

rewrite rules seem a little complicated in nginx (or just different), I
think I will be able to work my other rules out if somebody could help
me with these two.

Thank You, Matt

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,2537,2537#msg-2537
matt91 (Guest)
on 2009-06-02 14:13
(Received via mailing list)
figured them out:

rewrite ^/bg_sound_([^_]*)\.xspf$
/includes/bg_audio_player/bg_sound.php?tributeid=$1 break;
rewrite ^/adamcarter$ /tributedetails.php?name=elvis_adam_carter&page=1
break;

I have one problem now, that is that they are not processed by php as
the rewrites are in the "location /" and not "location ~.*php$", is
their any way to fix this other than putting the fastcgi lines in the
"location /" section?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,2537,2557#msg-2557
Jim O. (Guest)
on 2009-06-02 19:18
(Received via mailing list)
Please post your configuration file(s).

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,2537,2560#msg-2560
Cliff W. (Guest)
on 2009-06-02 20:39
(Received via mailing list)
On Tue, 2009-06-02 at 06:00 -0400, matt91 wrote:
> figured them out:
>
> rewrite ^/bg_sound_([^_]*)\.xspf
> $ /includes/bg_audio_player/bg_sound.php?tributeid=$1 break;
> rewrite ^/adamcarter
> $ /tributedetails.php?name=elvis_adam_carter&page=1 break;
>
> I have one problem now, that is that they are not processed by php as
> the rewrites are in the "location /" and not "location ~.*php$",

location ~ \.php$

> is their any way to fix this other than putting the fastcgi lines in
> the "location /" section?

You shouldn't need to.  Post your config file here.

Cliff
matt91 (Guest)
on 2009-06-02 23:44
(Received via mailing list)
Thank you for your help, I moved the rules into the main server section
and they work, why didn't I think of that. Planning on moving from
Apache later this week, some pages are loading around twice as fast as
apache.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,2537,2575#msg-2575
This topic is locked and can not be replied to.