容器技术交流

 找回密码
 立即注册
查看: 3776|回复: 6

麻烦高手帮转一下nginx伪静态规则

[复制链接]
发表于 2009-6-21 16:51:29 | 显示全部楼层 |阅读模式
  1. RewriteRule ^(.*)/product-(.+)-(.+)-(.+)/\?*(.*)$ $1/product_list\.php\?firstRow=$2&totalRows=$3&id=$4
复制代码


这句是apache的rewrite规则,麻烦高手帮我改为nginx的rewrite规则。

O(∩_∩)O谢谢!
发表于 2009-6-21 17:04:27 | 显示全部楼层
试试这个:
rewrite ^(.*)/product-(.+)-(.+)-(.+)/\?*(.*)$ $1/product_list\.php\?firstRow=$2&totalRows=$3&id=$4 last;
 楼主| 发表于 2009-6-23 01:00:49 | 显示全部楼层
因为规则不只1句,我按照洞洞老大的方法将rewriterule改为Rewrite,在句尾加last;依葫芦画瓢,结果出错。
以下是完整的apache rewrite规则。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)/product-(.+)-(.+)-(.+)/\?*(.*)$ $1/product_list\.php\?firstRow=$2&totalRows=$3&id=$4
RewriteRule ^(.*)/product-(.+)-(.+)/\?*(.*)$ $1/product_list\.php\?firstRow=$2&totalRows=$3
RewriteRule ^(.*)/product-(.+)/\?*(.*)$ $1/product_list\.php\?id=$2
RewriteRule ^(.*)/product/\?*(.*)$ $1/product_list\.php
RewriteRule ^(.*)/products-category/\?*(.*)$ $1/products_category\.php

RewriteRule ^(.*)/news-(.+)/\?*(.*)$ $1/news_detail\.php\?id=$2
RewriteRule ^(.*)/bizserver-(.+)-(.+)-(.+)/\?*(.*)$ $1/news_list\.php\?firstRow=$2&totalRows=$3&id=$4
RewriteRule ^(.*)/bizserver-(.+)/\?*(.*)$ $1/news_list\.php\?id=$2
RewriteRule ^(.*)/bizserver/\?*(.*)$ $1/biz_server\.php

RewriteRule ^(.*)/exhibition/\?*(.*)$ $1/exhibition\.php
RewriteRule ^(.*)/exhibition-detail/(.+)/\?*(.*)$ $1/exhibition_detail\.php\?id=$2
RewriteRule ^(.*)/exhibition-(.+)-(.+)/\?*(.*)$ $1/exhibition\.php\?firstRow=$2&totalRows=$3

RewriteRule ^(.*)/company-(.+)-(.+)-(.+)/\?*(.*)$ $1/company_list\.php\?firstRow=$2&totalRows=$3&id=$4
RewriteRule ^(.*)/company-(.+)-(.+)/\?*(.*)$ $1/company_list\.php\?firstRow=$2&totalRows=$3
RewriteRule ^(.*)/company-(.+)/\?*(.*)$ $1/company_list\.php\?id=$2
RewriteRule ^(.*)/company/\?*(.*)$ $1/company_list\.php
RewriteRule ^(.*)/companys-category/\?*(.*)$ $1/companys_category\.php

RewriteRule ^(.*)/user-space/(.+)-(.+)-(.+)-(.+)\?*(.*)$ $1/shop\.php\?firstRow=$4&totalRows=$5&uid=$3&action=$2
RewriteRule ^(.*)/user-space/(.+)-(.+)-(.+)\?*(.*)$ $1/shop\.php\?uid=$3&action=$2&id=$4
RewriteRule ^(.*)/user-space/(.+)-(.+)\?*(.*)$ $1/shop\.php\?uid=$2&action=$3
RewriteRule ^(.*)/user-space/(.+)/\?*(.*)$ $1/shop\.php\?uid=$2
RewriteRule ^(.*)/user-space/(.+)\?*(.*)$ $1/shop\.php\?uid=$2

RewriteRule ^(.*)/info-(.+)-(.+)-(.+)/\?*(.*)$ $1/buy_list\.php\?firstRow=$2&totalRows=$3&id=$4
RewriteRule ^(.*)/info-(.+)-(.+)/\?*(.*)$ $1/buy_list\.php\?firstRow=$2&totalRows=$3
RewriteRule ^(.*)/info-(.+)/\?*(.*)$ $1/buy_list\.php\?id=$2
RewriteRule ^(.*)/info/\?*(.*)$ $1/buy_list\.php
RewriteRule ^(.*)/information-(.+)/\?*(.*)$ $1/buy_list\.php\?limit=$2
RewriteRule ^(.*)/buy-category/\?*(.*)$ $1/buy_category\.php

RewriteRule ^(.*)/aboutus/\?*(.*)$ $1/aboutus\.php
RewriteRule ^(.*)/aboutus/(.+)\?*(.*)$ $1/aboutus\.php\?type=$2
RewriteRule ^(.*)/guide/\?*(.*)$ $1/guide\.php
RewriteRule ^(.*)/guide/(.+)\?*(.*)$ $1/guide\.php\?id=$2
RewriteRule ^(.*)/job/\?*(.*)$ $1/job\.php
RewriteRule ^(.*)/announcement/(.+)\?*(.*)$ $1/announcement\.php\?id=$2
RewriteRule ^(.*)/changelink/\?*(.*)$ $1/change_link\.php

</IfModule>

麻烦老大给我看看。

[ 本帖最后由 yesilike 于 2009-6-23 01:03 编辑 ]
发表于 2009-6-23 01:58:44 | 显示全部楼层
不确定了,好久没玩了,以前有一整套的(一口吃转了几程序的)
发表于 2009-6-23 11:10:15 | 显示全部楼层
  1. rewrite ^/(.*)/product-(.+)-(.+)-(.+)/\?*(.*)$ /$1/product_list\.php\?firstRow=$2&totalRows=$3&id=$4;
  2. rewrite ^/(.*)/product-(.+)-(.+)/\?*(.*)$ /$1/product_list\.php\?firstRow=$2&totalRows=$3;
  3. rewrite ^/(.*)/product-(.+)/\?*(.*)$ /$1/product_list\.php\?id=$2;
  4. rewrite ^/(.*)/product/\?*(.*)$ /$1/product_list\.php;
  5. rewrite ^/(.*)/products-category/\?*(.*)$ /$1/products_category\.php;
  6. rewrite ^/(.*)/news-(.+)/\?*(.*)$ /$1/news_detail\.php\?id=$2;
  7. rewrite ^/(.*)/bizserver-(.+)-(.+)-(.+)/\?*(.*)$ /$1/news_list\.php\?firstRow=$2&totalRows=$3&id=$4;
  8. rewrite ^/(.*)/bizserver-(.+)/\?*(.*)$ /$1/news_list\.php\?id=$2;
  9. rewrite ^/(.*)/bizserver/\?*(.*)$ /$1/biz_server\.php;
  10. rewrite ^/(.*)/exhibition/\?*(.*)$ /$1/exhibition\.php;
  11. rewrite ^/(.*)/exhibition-detail/(.+)/\?*(.*)$ /$1/exhibition_detail\.php\?id=$2;
  12. rewrite ^/(.*)/exhibition-(.+)-(.+)/\?*(.*)$ /$1/exhibition\.php\?firstRow=$2&totalRows=$3;
  13. rewrite ^/(.*)/company-(.+)-(.+)-(.+)/\?*(.*)$ /$1/company_list\.php\?firstRow=$2&totalRows=$3&id=$4;
  14. rewrite ^/(.*)/company-(.+)-(.+)/\?*(.*)$ /$1/company_list\.php\?firstRow=$2&totalRows=$3;
  15. rewrite ^/(.*)/company-(.+)/\?*(.*)$ /$1/company_list\.php\?id=$2;
  16. rewrite ^/(.*)/company/\?*(.*)$ /$1/company_list\.php;
  17. rewrite ^/(.*)/companys-category/\?*(.*)$ /$1/companys_category\.php;
  18. rewrite ^/(.*)/user-space/(.+)-(.+)-(.+)-(.+)\?*(.*)$ /$1/shop\.php\?firstRow=$4&totalRows=$5&uid=$3&action=$2;
  19. rewrite ^/(.*)/user-space/(.+)-(.+)-(.+)\?*(.*)$ /$1/shop\.php\?uid=$3&action=$2&id=$4;
  20. rewrite ^/(.*)/user-space/(.+)-(.+)\?*(.*)$ /$1/shop\.php\?uid=$2&action=$3;
  21. rewrite ^/(.*)/user-space/(.+)/\?*(.*)$ /$1/shop\.php\?uid=$2;
  22. rewrite ^/(.*)/user-space/(.+)\?*(.*)$ /$1/shop\.php\?uid=$2;
  23. rewrite ^/(.*)/info-(.+)-(.+)-(.+)/\?*(.*)$ /$1/buy_list\.php\?firstRow=$2&totalRows=$3&id=$4;
  24. rewrite ^/(.*)/info-(.+)-(.+)/\?*(.*)$ /$1/buy_list\.php\?firstRow=$2&totalRows=$3;
  25. rewrite ^/(.*)/info-(.+)/\?*(.*)$ /$1/buy_list\.php\?id=$2;
  26. rewrite ^/(.*)/info/\?*(.*)$ /$1/buy_list\.php;
  27. rewrite ^/(.*)/information-(.+)/\?*(.*)$ /$1/buy_list\.php\?limit=$2;
  28. rewrite ^/(.*)/buy-category/\?*(.*)$ /$1/buy_category\.php;
  29. rewrite ^/(.*)/aboutus/\?*(.*)$ /$1/aboutus\.php;
  30. rewrite ^/(.*)/aboutus/(.+)\?*(.*)$ /$1/aboutus\.php\?type=$2;
  31. rewrite ^/(.*)/guide/\?*(.*)$ /$1/guide\.php;
  32. rewrite ^/(.*)/guide/(.+)\?*(.*)$ /$1/guide\.php\?id=$2;
  33. rewrite ^/(.*)/job/\?*(.*)$ /$1/job\.php;
  34. rewrite ^/(.*)/announcement/(.+)\?*(.*)$ /$1/announcement\.php\?id=$2;
  35. rewrite ^/(.*)/changelink/\?*(.*)$ /$1/change_link\.php;
复制代码
 楼主| 发表于 2009-6-23 13:20:09 | 显示全部楼层
楼上的就是把RewriteRule的Rule去掉就可以了,是这样的吗?
发表于 2009-6-23 15:06:13 | 显示全部楼层
我也不知道,试试吧
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Archiver|URLOS ( 粤ICP备18087780号 )

GMT+8, 2025-7-12 11:44 , Processed in 0.026683 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表