VPS侦探论坛

 找回密码
 注册
查看: 7394|回复: 1

ecshop在lnmp下的伪静态问题

[复制链接]
发表于 2011-5-2 12:28:46 | 显示全部楼层 |阅读模式

ecshop搬家了,以前服务器是apache,现在是nginx
搬家之后问题来了,.htaccess不生效,网上查了一下说nginx不支持apache的重写规则,
结合网站的例子找了好久按照网上的步骤:在/usr/local/nginx/conf路径下建立了文件ecshop.conf
内容如下:

  1. if (!-e $request_filename)
  2. {
  3. rewrite "^/index\.html" /index.php last;
  4. rewrite "^/category$" /index.php last;
  5. rewrite "^/feed-c([0-9]+)\.xml$" /feed.php?cat=\$1 last;
  6. rewrite "^/feed-b([0-9]+)\.xml$" /feed.php?brand=\$1 last;
  7. rewrite "^/feed\.xml$" /feed.php last;
  8. rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=\$1&brand=\$2&price_min=\$3&price_max=\$4&filter_attr=\$5&page=\$6&sort=\$7&order=\$8 last;
  9. rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$" /category.php?id=\$1&brand=\$2&price_min=\$3&price_max=\$4&filter_attr=\$5 last;
  10. rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=\$1&brand=\$2&page=\$3&sort=\$4&order=\$5 last;
  11. rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$" /category.php?id=\$1&brand=\$2&page=\$3 last;
  12. rewrite "^/category-([0-9]+)-b([0-9]+)(.*)\.html$" /category.php?id=\$1&brand=\$2 last;
  13. rewrite "^/category-([0-9]+)(.*)\.html$" /category.php?id=\$1 last;
  14. rewrite "^/goods-([0-9]+)(.*)\.html" /goods.php?id=\$1 last;
  15. rewrite "^/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /article_cat.php?id=\$1&page=\$2&sort=\$3&order=\$4 last;
  16. rewrite "^/article_cat-([0-9]+)-([0-9]+)(.*)\.html$" /article_cat.php?id=\$1&page=\$2 last;
  17. rewrite "^/article_cat-([0-9]+)(.*)\.html$" /article_cat.php?id=\$1 last;
  18. rewrite "^/article-([0-9]+)(.*)\.html$" /article.php?id=\$1 last;
  19. rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html" /brand.php?id=\$1&cat=\$2&page=\$3&sort=\$4&order=\$5 last;
  20. rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html" /brand.php?id=\$1&cat=\$2&page=\$3 last;
  21. rewrite "^/brand-([0-9]+)-c([0-9]+)(.*)\.html" /brand.php?id=\$1&cat=\$2 last;
  22. rewrite "^/brand-([0-9]+)(.*)\.html" /brand.php?id=\$1 last;
  23. rewrite "^/tag-(.*)\.html" /search.php?keywords=\$1 last;
  24. rewrite "^/snatch-([0-9]+)\.html$" /snatch.php?id=\$1 last;
  25. rewrite "^/group_buy-([0-9]+)\.html$" /group_buy.php?act=view&id=\$1 last;
  26. rewrite "^/auction-([0-9]+)\.html$" /auction.php?act=view&id=\$1 last;
  27. rewrite "^/exchange-id([0-9]+)(.*)\.html$" /exchange.php?id=\$1&act=view last;
  28. rewrite "^/exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=\$1&integral_min=\$2&integral_max=\$3&page=\$4&sort=\$5&order=\$6 last;
  29. rewrite ^/exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=\$1&page=\$2&sort=\$3&order=\$4 last;
  30. rewrite "^/exchange-([0-9]+)-([0-9]+)(.*)\.html$" /exchange.php?cat_id=\$1&page=\$2 last;
  31. rewrite "^/exchange-([0-9]+)(.*)\.html$" /exchange.php?cat_id=\$1 last;
  32. }
复制代码
然后运行:/root/vhost.sh添加域名
到选择rewrite那一步的时候,填写ecshop.conf,顺利完成域名添加
成功后的域名配置文件/usr/local/nginx/conf/vhost/xxx.com.conf
代码如下:
  1. server
  2. {
  3. listen 80;
  4. server_name xxx.com www.xxx.com;
  5. index index.html index.htm index.php default.html default.htm default.php;
  6. root /home/wwwroot/www.xxx.com;

  7. include eshop.conf;
  8. location ~ .*\.(php|php5)?$
  9. {
  10. fastcgi_pass unix:/tmp/php-cgi.sock;
  11. fastcgi_index index.php;
  12. include fcgi.conf;
  13. }

  14. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  15. {
  16. expires 30d;
  17. }

  18. location ~ .*\.(js|css)?$
  19. {
  20. expires 12h;
  21. }

  22. access_log off;
  23. }
复制代码
点开内页的时候自动跳转到首页了,不知道什么问题,是方法搞错了吗,还是什么问题,期待解答。

[ 本帖最后由 vipmz 于 2011-5-6 12:20 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2011-5-2 13:37:30 | 显示全部楼层

回复 1# 的帖子



配置文件里是include eshop.conf;
你创建的是ecshop.conf

再就是最好上ecshop官网上找nginx伪静态试试。
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-20 12:09 , Processed in 0.025203 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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