# Rewrite rules in nginx config

**URL:** <https://www.ruby-forum.com/t/rewrite-rules-in-nginx-config/242760>\
**Category:** NGINX\
**Created:** [July 17, 2015, 5:12pm UTC](https://www.ruby-forum.com/t/rewrite-rules-in-nginx-config/242760 "2015-07-17T17:12:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [July 17, 2015, 5:12pm UTC](https://www.ruby-forum.com/t/rewrite-rules-in-nginx-config/242760/1 "2015-07-17T17:12:57Z")

</div>

Hi all,  
thank’s to accept me in this forum.

I’m a newbie… I have a problem with a rewrite rules that I imported  
from  
apache

This is my code

index home.php index.php;  
location / {  
rewrite ^/(._)?$ /categories.php?cat=$1;  
rewrite ^/(._).html?$ /game.php?game=$1;  
rewrite ^/(._)/(._).html?$ /game.php?game=$2 break;  
}

```
location /dists/ {
    # Do nothing. nginx will serve files as usual.
}

location /images/ {
    # Do nothing. nginx will serve files as usual.
}
location /admin/ {
    # Do nothing. nginx will serve files as usual.
}
location /css/ {
    # Do nothing. nginx will serve files as usual.
}
location /config/ {
    # Do nothing. nginx will serve files as usual.
}

```

I’d like ti take parameters from cat and game and use them to know the  
path.

This is oc, but so… all others directories don’t work.  
Is this configuration so insensitive?

Posted at Nginx Forum:

> **[Rewrite rules in nginx config](https://forum.nginx.org/read.php?2,260404,260404#msg-260404)**
>
> Hi all, thank's to accept me in this forum. I'm a newbie... I have a problem with a rewrite rules that I imported from apache This is my code index home.php index.php; location / { rewrite ^/(.\*)?$ /categories.php?cat=$1;

---

<div class="post-metadata">

**Author:** ![dr.net](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/67e7ee/32.png) [@dr.net](https://www.ruby-forum.com/u/dr.net)\
**Post date:** [July 17, 2015, 5:36pm UTC](https://www.ruby-forum.com/t/rewrite-rules-in-nginx-config/242760/2 "2015-07-17T17:36:54Z")

</div>

On Fri, Jul 17, 2015 at 4:12 PM, [dr.net](http://dr.net) [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> location / {  
> rewrite ^/(._)?$ /categories.php?cat=$1;  
> rewrite ^/(._).html?$ /game.php?game=$1;  
> rewrite ^/(._)/(._).html?$ /game.php?game=$2 break;  
> }

Before anything… you seem to want to serve PHP, but I don’t see  
anything in the config pointing to a php backend such as php-fpm…

> ```
> location /css/ {
> # Do nothing. nginx will serve files as usual.
> }
> location /config/ {
> # Do nothing. nginx will serve files as usual.
> }
> 
> ```

As for this locations you could simplify to just one whats the “root”  
path? you don’t seem to define one, unless you didn’t paste the full  
config.

---

<div class="post-metadata">

**Author:** ![dr.net](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/67e7ee/32.png) [@dr.net](https://www.ruby-forum.com/u/dr.net)\
**Post date:** [July 17, 2015, 6:04pm UTC](https://www.ruby-forum.com/t/rewrite-rules-in-nginx-config/242760/3 "2015-07-17T18:04:21Z")

</div>

Hi Mike, thank’s for reply.

I haven’t posted all the config because the server is maintained and I  
have  
to send to administrator only che rewrite config

The php-fpm works

Posted at Nginx Forum:

> **[Re: Rewrite rules in nginx config](https://forum.nginx.org/read.php?2,260404,260408#msg-260408)**
>
> Hi all, thank's to accept me in this forum. I'm a newbie... I have a problem with a rewrite rules that I imported from apache This is my code index home.php index.php; location / { rewrite ^/(.\*)?$ /categories.php?cat=$1;
