# Help on rewrite rule

**URL:** <https://www.ruby-forum.com/t/help-on-rewrite-rule/212917>\
**Category:** NGINX\
**Created:** [October 17, 2011, 10:25pm UTC](https://www.ruby-forum.com/t/help-on-rewrite-rule/212917 "2011-10-17T22:25:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [October 17, 2011, 10:25pm UTC](https://www.ruby-forum.com/t/help-on-rewrite-rule/212917/1 "2011-10-17T22:25:21Z")

</div>

Hi,

I’m fairly new when it comes to nginx and would like to basically  
rewrite the following:

/main.php → index.php

Can someone please give me an example how to do this? Thanks

Posted at Nginx Forum:

> **[Help on rewrite rule](https://forum.nginx.org/read.php?2,216843,216843#msg-216843)**
>
> Hi, I'm fairly new when it comes to nginx and would like to basically rewrite the following: /main.php --\> index.php Can someone please give me an example how to do this? Thanks

---

<div class="post-metadata">

**Author:** ![microchip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@microchip](https://www.ruby-forum.com/u/microchip)\
**Post date:** [October 17, 2011, 10:35pm UTC](https://www.ruby-forum.com/t/help-on-rewrite-rule/212917/2 "2011-10-17T22:35:51Z")

</div>

On 17 October 2011 23:24, microchip [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> I’m fairly new when it comes to nginx and would like to basically  
> rewrite the following:
> 
> /main.php → index.php
> 
> Can someone please give me an example how to do this? Thanks

rewrite ^/main.php(.\*) index.php$1;

Hopefully we are not having a case of the XY Problem here as it looks  
like you may be using Gallery2 … in which case you should be looking  
for Gallery2 rewrite rules.

---

<div class="post-metadata">

**Author:** ![microchip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@microchip](https://www.ruby-forum.com/u/microchip)\
**Post date:** [October 17, 2011, 10:37pm UTC](https://www.ruby-forum.com/t/help-on-rewrite-rule/212917/3 "2011-10-17T22:37:05Z")

</div>

On 17 October 2011 23:35, Nginx U. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> rewrite ^/main.php(._) index.php$1;  
> Sorry  
> rewrite ^/main.php(._) /index.php$1;

---

<div class="post-metadata">

**Author:** ![microchip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@microchip](https://www.ruby-forum.com/u/microchip)\
**Post date:** [October 17, 2011, 10:50pm UTC](https://www.ruby-forum.com/t/help-on-rewrite-rule/212917/4 "2011-10-17T22:50:05Z")

</div>

Thanks 🙂

and no, I’m not using Gallary2

Posted at Nginx Forum:

> **[Re: Help on rewrite rule](https://forum.nginx.org/read.php?2,216843,216849#msg-216849)**
>
> Hi, I'm fairly new when it comes to nginx and would like to basically rewrite the following: /main.php --\> index.php Can someone please give me an example how to do this? Thanks

---

<div class="post-metadata">

**Author:** ![microchip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@microchip](https://www.ruby-forum.com/u/microchip)\
**Post date:** [October 17, 2011, 10:48pm UTC](https://www.ruby-forum.com/t/help-on-rewrite-rule/212917/5 "2011-10-17T22:48:51Z")

</div>

18.10.2011, 03:36, “Nginx U.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> On 17 October 2011 23:35, Nginx U. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > rewrite ^/main.php(.\*) index.php$1;
> 
> Sorry  
> rewrite ^/main.php(.\*) /index.php$1;

forget about rewrite with nginx:

location = /main.php {  
fastcgi\_pass …  
fastcgi\_param SCRIPT\_NAME /index.php;  
fastcgi\_param SCRIPT\_FILENAME /path/to/index.php;  
}

–  
br, Denis F. Latypoff.
