Forum: NGINX Help with .htaccess rules

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.
C3ab146b8cf153e371e60a6f288f7188?d=identicon&s=25 Joe Shang (Guest)
on 2008-11-18 13:18
(Received via mailing list)
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
F5a6ed477b109fe6acc11a5a8f87e7e8?d=identicon&s=25 mike (Guest)
on 2008-11-18 21:47
(Received via mailing list)
I think you can use $query_string
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2008-11-18 22:42
(Received via mailing list)
On Tue, Nov 18, 2008 at 06:09:16AM -0600, Joe Shang 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;
This topic is locked and can not be replied to.