全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 5857|回复: 17

[疑问] 求教一下啊nginx下dz的伪静态设置 老是404 想死的心都有了

[复制链接]
发表于 2009-12-30 18:10:30 | 显示全部楼层 |阅读模式
求教一下啊nginx下dz的伪静态设置 老是404 想死的心都有了
本人菜鸟啊 配置代码如下 BBS目录是 home/wwwroot/bbs
请大虾们帮忙啊




server
        {
                listen       80;
                server_name www.yykafei.com;
                index index.html index.htm index.php;
                root  /home/wwwroot;

                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                #fastcgi_pass  127.0.0.1:9000;
                                fastcgi_index index.php;
                                include fcgi.conf;
                        }

location / {
index index.html index.htm index.php;
root  /home/wwwroot/bbs;
rewrite ^/archiver/((fid|tid)-[\w\-]+\.html)$   /archiver/index.php?$1 last;
rewrite ^/forum-([0-9]+)-([0-9]+)\.html$   /forumdisplay.php?fid=$1&page=$2 last;
rewrite ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$  /viewthread.php?tid=$1&extra=page\%3D$3&page=$2 last;
rewrite ^/space-(username|uid)-(.+)\.html$   /space.php?$1=$2 last;
rewrite ^/tag-(.+)\.html$ /tag.php?name=$1 last;
break;
}
发表于 2009-12-30 18:17:59 | 显示全部楼层
rewrite ^/bbs/archiver/((fid|tid)-[\w\-]+\.html)$   /bbs/archiver/index.php?$1 last;
rewrite ^/bbs/forum-([0-9]+)-([0-9]+)\.html$   /bbs/forumdisplay.php?fid=$1&page=$2 last;
rewrite ^/bbs/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /bbs /viewthread.php?tid=$1&extra=page\%3D$3&page=$2 last;
rewrite ^/bbs/space-(username|uid)-(.+)\.html$  /bbs /space.php?$1=$2 last;
rewrite ^/bbs/tag-(.+)\.html$ /bbs/tag.php?name=$1 last;
发表于 2009-12-30 18:31:52 | 显示全部楼层

回复 1# 的帖子

location /bbs/

这个子目录内则。
发表于 2009-12-30 18:34:38 | 显示全部楼层
还是老大的技术牛啊
 楼主| 发表于 2009-12-30 18:50:40 | 显示全部楼层

回复 3# 的帖子

是这样吗?还是不行啊
location /bbs/ {
index index.html index.htm index.php;
root  /home/wwwroot/bbs;
rewrite ^/bbs/archiver/((fid|tid)-[\w\-]+\.html)$   /bbs/archiver/index.php?$1 last;
rewrite ^/bbs/forum-([0-9]+)-([0-9]+)\.html$   /bbs/forumdisplay.php?fid=$1&page=$2 last;
rewrite ^/bbs/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /bbs /viewthread.php?tid=$1&extra=page\%3D$3&page=$2 last;
rewrite ^/bbs/space-(username|uid)-(.+)\.html$  /bbs /space.php?$1=$2 last;
rewrite ^/bbs/tag-(.+)\.html$ /bbs/tag.php?name=$1 last;
break;
}
发表于 2009-12-30 19:41:33 | 显示全部楼层

回复 1# 的帖子



location / bbs/ {
rewrite ^(.*)/archiver/((fid|tid)-[\w\-]+\.html)$ $1/archiver/index.php?$2 last;
rewrite ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&page=$3 last;
rewrite ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^(.*)/profile-(username|uid)-(.+)\.html$ $1/viewpro.php?$2=$3 last;
rewrite ^(.*)/space-(username|uid)-(.+)\.html$ $1/space.php?$2=$3 last;
rewrite ^(.*)/tag-(.+)\.html$ $1/tag.php?name=$2 last;
}

放到
                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                #fastcgi_pass  127.0.0.1:9000;
                                fastcgi_index index.php;
                                include fcgi.conf;
                        }

之前,然后测试下nginx -t 语法是否有错。
 楼主| 发表于 2009-12-30 20:10:44 | 显示全部楼层

回复 6# 的帖子

c大啊 还是不行啊 nginx也重启了 问问nginx -t这个命令怎么用的啊 更目录下直接输没用 小白了
server
        {
                listen       80;
                server_name www.yykafei.com;
                index index.html index.htm index.php;
                root  /home/wwwroot;

location / bbs/ {
rewrite ^(.*)/archiver/((fid|tid)-[\w\-]+\.html)$ $1/archiver/index.php?$2 last;
rewrite ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&page=$3 last;
rewrite ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^(.*)/profile-(username|uid)-(.+)\.html$ $1/viewpro.php?$2=$3 last;
rewrite ^(.*)/space-(username|uid)-(.+)\.html$ $1/space.php?$2=$3 last;
rewrite ^(.*)/tag-(.+)\.html$ $1/tag.php?name=$2 last;
}

                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                #fastcgi_pass  127.0.0.1:9000;
                                fastcgi_index index.php;
                                include fcgi.conf;
                        }


                          location /status {
                        stub_status on;
                        access_log   off;
                }
发表于 2009-12-30 20:24:20 | 显示全部楼层

回复 7# 的帖子

location /status {
                        stub_status on;
                        access_log   off;
                }

这段请删除,你的这个server段放stub_status on; 可不行。

nginx配置文件语法测试命令 /usr/local/nginx/sbin/nginx -t
发表于 2009-12-30 20:30:04 | 显示全部楼层
汗~~~
 楼主| 发表于 2009-12-30 20:41:11 | 显示全部楼层

回复 8# 的帖子

发个完整的C大帮忙看一下吧 心都碎了 有空了要加强学习啦


[root@** ~]# /usr/local/nginx/sbin/nginx -t
[emerg]: invalid location modifier "/" in /usr/local/nginx/conf/nginx.conf:62
configuration file /usr/local/nginx/conf/nginx.conf test failed
  1. user  www www;

  2. worker_processes 1;

  3. error_log  /home/wwwroot/logs/nginx_error.log  crit;

  4. pid        /usr/local/nginx/logs/nginx.pid;

  5. #Specifies the value for maximum file descriptors that can be opened by this process.
  6. worker_rlimit_nofile 51200;

  7. events
  8.         {
  9.                 use epoll;
  10.                 worker_connections 51200;
  11.         }

  12. http
  13.         {
  14.                 include       mime.types;
  15.                 default_type  application/octet-stream;

  16.                 #charse  gb2312;

  17.                 server_names_hash_bucket_size 128;
  18.                 client_header_buffer_size 32k;
  19.                 large_client_header_buffers 4 32k;
  20.                 client_max_body_size 8m;

  21.                 sendfile on;
  22.                 tcp_nopush     on;

  23.                 keepalive_timeout 60;

  24.                 tcp_nodelay on;

  25.                 fastcgi_connect_timeout 300;
  26.                 fastcgi_send_timeout 300;
  27.                 fastcgi_read_timeout 300;
  28.                 fastcgi_buffer_size 64k;
  29.                 fastcgi_buffers 4 64k;
  30.                 fastcgi_busy_buffers_size 128k;
  31.                 fastcgi_temp_file_write_size 256k;

  32.                 gzip on;
  33.                 gzip_min_length  1k;
  34.                 gzip_buffers     4 16k;
  35.                 gzip_http_version 1.0;
  36.                 gzip_comp_level 2;
  37.                 gzip_types       text/plain application/x-javascript text/css application/xml;
  38.                 gzip_vary on;

  39.                 #limit_zone  crawler  $binary_remote_addr  10m;

  40. server
  41.         {
  42.                 listen       80;
  43.                 server_name www.yykafei.com;
  44.                 index index.html index.htm index.php;
  45.                 root  /home/wwwroot;

  46. location / bbs/ {
  47. rewrite ^(.*)/archiver/((fid|tid)-[\w\-]+\.html)$ $1/archiver/index.php?$2 last;
  48. rewrite ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&page=$3 last;
  49. rewrite ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=$3 last;
  50. rewrite ^(.*)/profile-(username|uid)-(.+)\.html$ $1/viewpro.php?$2=$3 last;
  51. rewrite ^(.*)/space-(username|uid)-(.+)\.html$ $1/space.php?$2=$3 last;
  52. rewrite ^(.*)/tag-(.+)\.html$ $1/tag.php?name=$2 last;
  53. }

  54.                 location ~ .*\.(php|php5)?$
  55.                         {
  56.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  57.                                 #fastcgi_pass  127.0.0.1:9000;
  58.                                 fastcgi_index index.php;
  59.                                 include fcgi.conf;
  60.                         }

  61.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  62.                         {
  63.                                 expires      30d;
  64.                         }

  65.                 location ~ .*\.(js|css)?$
  66.                         {
  67.                                 expires      12h;



  68.                 log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  69.              '$status $body_bytes_sent "$http_referer" '
  70.              '"$http_user_agent" $http_x_forwarded_for';
  71.                 access_log  /home/wwwroot/logs/access.log  access;
  72.         }
  73. include vhost/*.conf;
  74. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-5-6 15:53 , Processed in 0.061863 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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