VPS侦探论坛

 找回密码
 注册
查看: 10275|回复: 5

nginx伪静态设置问题

[复制链接]
发表于 2010-6-2 14:32:21 | 显示全部楼层 |阅读模式

请各位成功设置nginx伪静态的朋友,指点一下.无论如何设置都不能在网站前台实现.按着帖子上面的方法试过N次了,还没有没有设置好.望走过看过的朋友留意,谢谢!
  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name www.esinomarr.com;
  5.                 index index.html index.htm index.php;
  6.                 root  /home/wwwroot/;
  7.                 location ~ .*\.(php|php5)?$
  8.                         {
  9.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  10.                                 fastcgi_index index.php;
  11.                                 include fcgi.conf;
  12.                         }
  13.               
  14.               if (!-e $request_filename) {
  15.         RewriteEngine On
  16.         RewriteBase /
  17.         RewriteCond %{REQUEST_FILENAME} !-f
  18.         RewriteCond %{REQUEST_FILENAME} !-d
  19.         RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]
  20.               }
  21.               
  22.                 location /status {
  23.                         stub_status on;
  24.                         access_log   off;
  25.                 }

  26.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  27.                         {
  28.                                 expires      30d;
  29.                         }

  30.                 location ~ .*\.(js|css)?$
  31.                         {
  32.                                 expires      12h;
  33.                         }

  34.                 log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  35.              '$status $body_bytes_sent "$http_referer" '
  36.              '"$http_user_agent" $http_x_forwarded_for';
  37.                 access_log  /home/wwwroot/logs/access.log  access;
  38.         }
  39. include vhost/*.conf;
  40. }
复制代码
另外一个方法也行不通
  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name www.esinomarr.com;
  5.                 index index.html index.htm index.php;
  6.                 root  /home/wwwroot/;
  7.                 include rewrite.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.               
  15.               
  16.                 location /status {
  17.                         stub_status on;
  18.                         access_log   off;
  19.                 }

  20.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  21.                         {
  22.                                 expires      30d;
  23.                         }

  24.                 location ~ .*\.(js|css)?$
  25.                         {
  26.                                 expires      12h;
  27.                         }

  28.                 log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  29.              '$status $body_bytes_sent "$http_referer" '
  30.              '"$http_user_agent" $http_x_forwarded_for';
  31.                 access_log  /home/wwwroot/logs/access.log  access;
  32.         }
  33. include vhost/*.conf;
  34. }
复制代码
下面是rewrite.conf代码
  1. # 1.To use URL Alias you need to be running apache with mod_rewrite enabled.

  2. # 2. In your opencart directory rename htaccess.txt to .htaccess.

  3. # For any support issues please visit: http://www.opencart.com

  4. Options +FollowSymlinks

  5. RewriteEngine On
  6. RewriteBase /
  7. RewriteCond %{REQUEST_FILENAME} !-f
  8. RewriteCond %{REQUEST_FILENAME} !-d
  9. RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]
复制代码

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

回复 1# 的帖子



你rewrite.conf里面写的是apache的伪静态肯定不能用在nginx上,你上官网看看或搜索一下有没有opencart的nginx伪静态。或者用http://www.anilcetin.com/convert-apache-htaccess-to-nginx/ 转换试试
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2010-6-2 16:07:54 | 显示全部楼层

为静态一点问题都没有, 参考我的帖子.

qun.baowang.com  都已经是伪静态了.
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2010-6-2 16:17:01 | 显示全部楼层



感谢军哥的指导.已经成功静态!希望可以帮到其他跟我一样的新手.
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2010-6-2 19:14:53 | 显示全部楼层

回复 4# 的帖子


军哥运维代购:http://shop63846532.taobao.com/

发表于 2011-4-5 16:39:22 | 显示全部楼层

www.23152316.com 伪静态成功
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-20 05:37 , Processed in 0.026829 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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