全球主机交流论坛

标题: 求ngnix下,子目录的伪静态规则写法? [打印本页]

作者: vieway    时间: 2010-10-30 12:53
标题: 求ngnix下,子目录的伪静态规则写法?
我在BURST上安装好了vpser的lnmp,在/home/wwwroot/blog目录下放了一下WP程序,而且这个网站的conf文件里也使用include包含了wordpress.conf这个伪静态规则, 但是我重启lnmp后, WP后台的固定链接里依然有index.php这样的东西, 请问这个问题怎样解决?

这个是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. }
复制代码

作者: Globalization    时间: 2010-10-30 13:20
  1. location / {
  2. if (-f $request_filename/index.html){
  3.                 rewrite (.*) $1/zimulu/index.html break;
  4.         }
  5. if (-f $request_filename/index.php){
  6.                 rewrite (.*) $1/zimulu/index.php;
  7.         }
  8. if (!-f $request_filename){
  9.                 rewrite (.*) /zimulu/index.php;
  10.         }
  11. }
复制代码
不知道对不对
作者: vieway    时间: 2010-10-30 13:22
原帖由 Globalization 于 2010-10-30 13:20 发表
location / {
if (-f $request_filename/index.html){
                rewrite (.*) $1/zimulu/index.html break;
        }
if (-f $request_filename/index.php){
                rewrite (.*) $1/zimulu/index. ...


zimulu是子目录的意思啊? 我的子目录是wiki
作者: 小夜    时间: 2010-10-30 13:26
你不会弄个2级域名嘛。例如 wiki.your.com 。
作者: Globalization    时间: 2010-10-30 13:29
  1. location / {
  2. if (-f $request_filename/index.html){
  3.                 rewrite (.*) $1/blog/index.html break;
  4.         }
  5. if (-f $request_filename/index.php){
  6.                 rewrite (.*) $1/blog/index.php;
  7.         }
  8. if (!-f $request_filename){
  9.                 rewrite (.*) /blog/index.php;
  10.         }
  11. }
复制代码

作者: nike_tool    时间: 2010-10-30 13:48
有点搞不懂你,只有把那个目录绑定一个域名,不就省事了吗
作者: vieway    时间: 2010-10-30 13:50
原帖由 小夜 于 2010-10-30 13:26 发表
你不会弄个2级域名嘛。例如 wiki.your.com 。


是啊, 我在这个VPS上放了两个站, 而且是不同域名的, 放在wwwroot目录下的站可以实现伪静态和静态, 可是放在wwwroot/blog下的WP程序就是实现不了, 老是404错误,固定链接那里也是出现index.php这样的东西, 所以就想问一下大家怎样设置规则,我想主要是路径的问题
作者: vieway    时间: 2010-10-30 13:51
原帖由 nike_tool 于 2010-10-30 13:48 发表
有点搞不懂你,只有把那个目录绑定一个域名,不就省事了吗


子目录是单独域名的,访问没有问题, 就是实现不了伪静态
作者: nike_tool    时间: 2010-10-30 13:52
把你的配置代码 贴出来看看
作者: serverpoint    时间: 2010-10-30 13:53
提示: 作者被禁止或删除 内容自动屏蔽
作者: vieway    时间: 2010-10-30 13:54
原帖由 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目录下
作者: nike_tool    时间: 2010-10-30 13:56
标题: 回复 11# 的帖子
全部的  server那几段

nginx.conf的代码
作者: vieway    时间: 2010-10-30 13:59
原帖由 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. }

复制代码

作者: nike_tool    时间: 2010-10-30 14:14
location / {
作用是全局,  要是使用到你的子目录  对应上的子目录路径
作者: vieway    时间: 2010-10-30 14:17
原帖由 nike_tool 于 2010-10-30 14:14 发表
location / {
作用是全局,  要是使用到你的子目录  对应上的子目录路径


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

[ 本帖最后由 vieway 于 2010-10-30 14:18 编辑 ]
作者: nike_tool    时间: 2010-10-30 14:26
nginx的伪静态 是在nginx.conf里面配置的
作者: foxlovefox    时间: 2010-10-30 14: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;
        }
}
试试




欢迎光临 全球主机交流论坛 (https://sunk.eu.org/) Powered by Discuz! X3.4