全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 7506|回复: 69
打印 上一主题 下一主题

nginx下的wordpress固定连接

[复制链接]
跳转到指定楼层
1#
发表于 2009-11-1 11:05:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个是主机配置文件

server
{
  listen       80;
  server_name www.abc.com;
  index index.html index.htm index.php;
  root  /web/www/abc;
  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 ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
   {
    expires      30d;
   }
  location ~ .*\.(js|css)?$
   {
    expires      12h;
   }
  access_log   off;
}


www.adc.com是域名,在abc.com/blog下有个博客是wordpress的,
找到的wordpress在nginx下的规则是


location / {
        index index.html index.htm index.php;
        root /home/www/abc/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;
        }
}


红体字那部分写的对吗?
2#
发表于 2009-11-1 11:19:21 | 只看该作者
那个跟wordpress固定连接一点关系都没有

是你的主目录路径
  1. if (-f $request_filename/index.html){
  2.                 rewrite (.*) $1/index.html break;
  3.         }
  4.         if (-f $request_filename/index.php){
  5.                 rewrite (.*) $1/index.php;
  6.         }
  7.         if (!-f $request_filename){
  8.                 rewrite (.*) /index.php;
  9.         }
  10. }
复制代码
这个才是关系性的固定链接,也就是rewrite规则.
我也是用这段代码,基本正常.

[ 本帖最后由 rdpof 于 2009-11-1 11:20 编辑 ]
3#
发表于 2009-11-1 11:22:45 | 只看该作者
我一直用这个rewrite规则,多简单:

                if (!-e $request_filename) {
                        rewrite ^(.*)$ /index.php?q=$1 last;
                }
4#
 楼主| 发表于 2009-11-1 11:23:29 | 只看该作者

回复 2# 的帖子

这句代码该怎么写啊,我都给弄糊涂了,网上说啥的也有,可能是环境不太一样吧,所以我也一直没有成功,
你可以帮我把这个修改下吗?

server
{
  listen       80;
  server_name www.abc.com;
  index index.html index.htm index.php;
  root  /web/www/abc;
  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 ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
   {
    expires      30d;
   }
  location ~ .*\.(js|css)?$
   {
    expires      12h;
   }
  access_log   off;
}
谢谢了。
5#
 楼主| 发表于 2009-11-1 11:24:02 | 只看该作者

回复 3# 的帖子

用了你那个了,我这里不行的。
6#
发表于 2009-11-1 11:33:44 | 只看该作者
原帖由 gdtv 于 2009-11-1 11:22 发表
我一直用这个rewrite规则,多简单:

                if (!-e $request_filename) {
                        rewrite ^(.*)$ /index.php?q=$1 last;
                }


我以前测试也是用的你这个规则
7#
 楼主| 发表于 2009-11-1 11:38:25 | 只看该作者

回复 6# 的帖子

能用吗?
8#
发表于 2009-11-1 11:40:14 | 只看该作者
server
        {
                listen       80;
                server_name www.abc.com;
                index index.html index.htm index.php;
                root  /web/www/abc;

                #limit_conn   crawler  20;

                #location /status {
                #stub_status    on;
                #access_log     off;
                #}

                if (!-e $request_filename) {
                        rewrite ^(.*)$ /index.php?q=$1 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 ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                        {
                                expires      30d;
                        }

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

                log_format  access1  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
                access_log  /web/logs/access.log  access;
        }

改写成这样应该就OK了。
9#
发表于 2009-11-1 11:40:38 | 只看该作者
原帖由 遍地阳光 于 2009-11-1 11:38 发表
能用吗?


可以。
10#
 楼主| 发表于 2009-11-1 11:41:55 | 只看该作者

回复 9# 的帖子

其实,我一直想typecho的,也是无法去掉固定连接里额。index.php
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-11-12 04:12 , Processed in 0.101788 second(s), 6 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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