# Help with .htaccess rules

**URL:** <https://www.ruby-forum.com/t/help-with-htaccess-rules/153530>\
**Category:** NGINX\
**Created:** [November 18, 2008, 1:18pm UTC](https://www.ruby-forum.com/t/help-with-htaccess-rules/153530 "2008-11-18T13:18:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsimone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jsimone](https://www.ruby-forum.com/u/jsimone)\
**Post date:** [November 18, 2008, 1:18pm UTC](https://www.ruby-forum.com/t/help-with-htaccess-rules/153530/1 "2008-11-18T13:18:10Z")

</div>

May seem like cheating posting this on here, but kinda stuck on this,  
as we are helping move alot of shared customers to nginx.

Stuck on these:

RewriteRule ^(._)-p-(._).html$  
index.php?main\_page=product\_info&products\_id=$2&%{QUERY\_STRING} [L]  
RewriteRule ^(._)-c-(._).html$  
index.php?main\_page=index&cPath=$2&%{QUERY\_STRING} [L]  
RewriteRule ^(._)-m-([0-9]+).html$  
index.php?main\_page=index&manufacturers\_id=$2&%{QUERY\_STRING} [L]  
RewriteRule ^(._)-pi-([0-9]+).html$  
index.php?main\_page=popup\_image&pID=$2&%{QUERY\_STRING} [L]  
RewriteRule ^(._)-pr-([0-9]+).html$  
index.php?main\_page=product\_reviews&products\_id=$2&%{QUERY\_STRING}  
[L]  
RewriteRule ^(._)-pri-([0-9]+).html$  
index.php?main\_page=product\_reviews\_info&products\_id=$2&%{QUERY\_STRING}  
[L]

How would these look in nginx?

Is it like:

rewrite ^/(._)-p-(._).html$  
index.php?main\_page=product\_info&products\_id=$2&% last;  
rewrite ^/(._)-c-(._).html$ index.php?main\_page=index&cPath=$2&% last;  
rewrite ^/(._)-m-([0-9]+).html$  
index.php?main\_page=index&manufacturers\_id=$2&% last;  
rewrite ^/(._)-pi-([0-9]+).html$  
index.php?main\_page=popup\_image&pID=$2&% last;  
rewrite ^/(.\*)-pr-([0-9]+).html$  
index.php?main\_page=product\_reviews&products\_id=$2&% last;

?

May seem stupid of me, but just not sure how would “{QUERY\_STRING}”  
would be placed here on nginx from .htaccess, nginx doesn’t even  
recognize it.

Thanks!

Joe

---

<div class="post-metadata">

**Author:** ![jsimone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jsimone](https://www.ruby-forum.com/u/jsimone)\
**Post date:** [November 18, 2008, 9:47pm UTC](https://www.ruby-forum.com/t/help-with-htaccess-rules/153530/2 "2008-11-18T21:47:32Z")

</div>

I think you can use $query\_string

---

<div class="post-metadata">

**Author:** ![jsimone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jsimone](https://www.ruby-forum.com/u/jsimone)\
**Post date:** [November 18, 2008, 10:42pm UTC](https://www.ruby-forum.com/t/help-with-htaccess-rules/153530/3 "2008-11-18T22:42:09Z")

</div>

On Tue, Nov 18, 2008 at 06:09:16AM -0600, Joe S. wrote:

> index.php?main\_page=index&manufacturers\_id=$2&%{QUERY\_STRING} [L]
> 
> index.php?main\_page=product\_reviews&products\_id=$2&% last;
> 
> ?
> 
> May seem stupid of me, but just not sure how would “{QUERY\_STRING}”  
> would be placed here on nginx from .htaccess, nginx doesn’t even  
> recognize it.

Use

rewrite ^/(._)-p-(._).html$

- 

```
     index\.php?main_page=product_info&products_id=$2&% last;

```

- 

```
     /index.php?main_page=product_info&products_id=$2 last;

```

nginx will add $args ($qeury\_string) by itself.  
If you want to omit it, then add “?” in the end:

- 

```
     /index.php?main_page=product_info&products_id=$2 last;

```

- 

```
     /index.php?main_page=product_info&products_id=$2? last;
```
