# Rewrite rule from apache

**URL:** <https://www.ruby-forum.com/t/rewrite-rule-from-apache/169295>\
**Category:** NGINX\
**Created:** [June 2, 2009, 1:09am UTC](https://www.ruby-forum.com/t/rewrite-rule-from-apache/169295 "2009-06-02T01:09:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![matt91](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3e96dc/32.png) [@matt91](https://www.ruby-forum.com/u/matt91)\
**Post date:** [June 2, 2009, 1:09am UTC](https://www.ruby-forum.com/t/rewrite-rule-from-apache/169295/1 "2009-06-02T01:09:10Z")

</div>

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:

> **[rewrite rule from apache](https://forum.nginx.org/read.php?2,2537,2537#msg-2537)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![matt91](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3e96dc/32.png) [@matt91](https://www.ruby-forum.com/u/matt91)\
**Post date:** [June 2, 2009, 12:13pm UTC](https://www.ruby-forum.com/t/rewrite-rule-from-apache/169295/2 "2009-06-02T12:13:51Z")

</div>

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:

> **[Re: rewrite rule from apache](https://forum.nginx.org/read.php?2,2537,2557#msg-2557)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![matt91](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3e96dc/32.png) [@matt91](https://www.ruby-forum.com/u/matt91)\
**Post date:** [June 2, 2009, 5:18pm UTC](https://www.ruby-forum.com/t/rewrite-rule-from-apache/169295/3 "2009-06-02T17:18:10Z")

</div>

Please post your configuration file(s).

Posted at Nginx Forum:

> **[Re: rewrite rule from apache](https://forum.nginx.org/read.php?2,2537,2560#msg-2560)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![matt91](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3e96dc/32.png) [@matt91](https://www.ruby-forum.com/u/matt91)\
**Post date:** [June 2, 2009, 9:44pm UTC](https://www.ruby-forum.com/t/rewrite-rule-from-apache/169295/4 "2009-06-02T21:44:45Z")

</div>

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:

> **[Re: rewrite rule from apache](https://forum.nginx.org/read.php?2,2537,2575#msg-2575)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![matt91](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3e96dc/32.png) [@matt91](https://www.ruby-forum.com/u/matt91)\
**Post date:** [June 2, 2009, 6:39pm UTC](https://www.ruby-forum.com/t/rewrite-rule-from-apache/169295/5 "2009-06-02T18:39:48Z")

</div>

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
