产品
发信息,接订单,就选一呼百应网
回答 6 2022-03-26 23:53

[已解决]Apache Rewrite 改成 Nginx Rewrite,请大家帮帮忙!

已解决 悬赏分:80 - 解决时间 2022-03-27 22:58
我使用的是Nginx的服务器,不知道怎么把官方的Apache重写规则改成Nginx下的?
下面这个是Apache下的重写代码,请大家帮帮忙帮我改下,谢谢!
  1. RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
  2. RewriteRule ^(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$ $1/show.php?itemid=$2&page=$4
  3. RewriteRule ^(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$ $1/list.php?catid=$2&page=$4
  4. RewriteRule ^(.*)/show/([0-9]+)/([0-9]+)?([/])?$ $1/show.php?itemid=$2&page=$3
  5. RewriteRule ^(.*)/list/([0-9]+)/([0-9]+)?([/])?$ $1/list.php?catid=$2&page=$3
  6. RewriteRule ^(.*)/([a-z0-9]+)\.co/(.*)$ $1/company/index.php?homepage=$2&rewrite=$3
  7. RewriteRule ^(.*)/htm/(.*)$ $1/index.php?&rewrite=$2
复制代码

[ ]
反对 0举报收藏 0
最佳答案
支持 0 反对 0 举报 2022-03-27 01:21
我使用的...
支持 0 反对 0 举报 2022-03-27 01:48
我使用的是Nginx的服务器,不知道怎么把官方的Apache重写规则改成Nginx下的?
下面这个是Apache下的重写代码,请大家帮帮忙帮我改下,谢谢!
  1. RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
  2. RewriteRule ^(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$ $1/show.php?itemid=$2&page=$4
  3. RewriteRule ^(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$ $1/list.php?catid=$2&page=$4
  4. RewriteRule ^(.*)/show/([0-9]+)/([0-9]+)?([/])?$ $1/show.php?itemid=$2&page=$3
  5. RewriteRule ^(.*)/list/([0-9]+)/([0-9]+)?([/])?$ $1/list.php?catid=$2&page=$3
  6. RewriteRule ^(.*)/([a-z0-9]+)\.co/(.*)$ $1/company/index.php?homepage=$2&rewrite=$3
  7. RewriteRule ^(.*)/htm/(.*)$ $1/index.php?&rewrite=$2
复制代码
[ 本帖最后由 osthink 于 2010-1-28 16:32 编辑 ]
支持 0 反对 0 举报 2022-03-27 02:07
http://www.**.com/convert-apache-htaccess-to-nginx/
支持 0 反对 0 举报 2022-03-27 03:05
  1. Rewrite ^(.*)-htm-(.*)$ $1.php?$2
  2. Rewrite "^(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$" $1/show.php?itemid=$2&page=$4
  3. Rewrite "^(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$" $1/list.php?catid=$2&page=$4
  4. Rewrite "^(.*)/show/([0-9]+)/([0-9]+)?([/])?$" $1/show.php?itemid=$2&page=$3
  5. Rewrite "^(.*)/list/([0-9]+)/([0-9]+)?([/])?$" $1/list.php?catid=$2&page=$3
  6. Rewrite "^(.*)/([a-z0-9]+)\.co/(.*)$" $1/company/index.php?homepage=$2&rewrite=$3
  7. Rewrite "^(.*)/htm/(.*)$" $1/index.php?&rewrite=$2
复制代码

是不是改成这样就可以了呢?
支持 0 反对 0 举报 2022-03-27 04:16
  1. rewrite ^/(.*)-htm-(.*)$ /$1.php?$2;
  2. rewrite ^/(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$ /$1/show.php?itemid=$2&page=$4;
  3. rewrite ^/(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$ /$1/list.php?catid=$2&page=$4;
  4. rewrite ^/(.*)/show/([0-9]+)/([0-9]+)?([/])?$ /$1/show.php?itemid=$2&page=$3;
  5. rewrite ^/(.*)/list/([0-9]+)/([0-9]+)?([/])?$ /$1/list.php?catid=$2&page=$3;
  6. rewrite ^/([a-z0-9]+)\.co/(.*)$ /company/index.php?homepage=$1&rewrite=$2;
  7. rewrite ^/(htm)/(.*)$ /index.php?&rewrite=$2;
复制代码

感谢管理员!
支持 0 反对 0 举报 2022-03-27 05:43
顶楼主~~~不错哦。。。