全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
12
返回列表 发新帖
楼主: vieway

[nginx] 求ngnix下,子目录的伪静态规则写法?

[复制链接]
 楼主| 发表于 2010-10-30 13:54:53 | 显示全部楼层
原帖由 nike_tool 于 2010-10-30 13:52 发表
把你的配置代码 贴出来看看


这个是wordpress.conf的
  1. location / {
  2. if (-f $request_filename/index.html){
  3.                 rewrite (.*) $1/index.html break;
  4.         }
  5. if (-f $request_filename/index.php){
  6.                 rewrite (.*) $1/index.php;
  7.         }
  8. if (!-f $request_filename){
  9.                 rewrite (.*) /index.php;
  10.         }
  11. }
复制代码


wordpress程序放在/home/wwwroot/blog目录下
发表于 2010-10-30 13:56:13 | 显示全部楼层

回复 11# 的帖子

全部的  server那几段

nginx.conf的代码
 楼主| 发表于 2010-10-30 13:59:03 | 显示全部楼层
原帖由 nike_tool 于 2010-10-30 13:56 发表
全部的  server那几段

nginx.conf的代码


这个是nginx.conf的


  1. server
  2. {
  3.   listen       80;
  4.   server_name vieway.net;
  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.   location /status {
  14.    stub_status on;
  15.    access_log   off;
  16.   }
  17.   location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  18.    {
  19.     expires      30d;
  20.    }
  21.   location ~ .*\.(js|css)?$
  22.    {
  23.     expires      12h;
  24.    }
  25.   log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  26.              '$status $body_bytes_sent "$http_referer" '
  27.              '"$http_user_agent" $http_x_forwarded_for';
  28.   access_log  /home/wwwlogs/access.log  access;
  29. }
  30. include vhost/*.conf;
  31. }

复制代码
发表于 2010-10-30 14:14:40 | 显示全部楼层
location / {
作用是全局,  要是使用到你的子目录  对应上的子目录路径
 楼主| 发表于 2010-10-30 14:17:17 | 显示全部楼层
原帖由 nike_tool 于 2010-10-30 14:14 发表
location / {
作用是全局,  要是使用到你的子目录  对应上的子目录路径


具体是怎样添加呢? 我是小菜鸟一个, 是需要修改nginx.conf, 还是wordpress.conf?

[ 本帖最后由 vieway 于 2010-10-30 14:18 编辑 ]
发表于 2010-10-30 14:26:55 | 显示全部楼层
nginx的伪静态 是在nginx.conf里面配置的
发表于 2010-10-30 14:46:46 | 显示全部楼层
在nginx.conf下添加

location /blog {
if (-f $request_filename/index.html){
                rewrite (.*) $1/index.html break;
        }
if (-f $request_filename/index.php){
                rewrite (.*) $1/index.php;
        }
if (!-f $request_filename){
                rewrite (.*) /index.php;
        }
}
试试
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-17 00:46 , Processed in 0.061147 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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