Nginx+重定向插件中断固定链接

时间:2012-06-29 作者:Thomas Thorogood

我正在从Apache迁移到Nginx。一切都很好,除非我有Redirection plugin 已启用。在这种情况下,除了主页外,我无法访问网站上的任何页面。它们都返回404错误。如果我再次禁用插件,我就能正常浏览我的网站。

我的Nginx配置如下:

upstream php 
{
    server 127.0.0.1:9000;
}

    server
    {
        listen  80; 
        root    /home/clearpointccs/public;
        server_name www.clearpointcreditcounselingsolutions.org clearpointcreditcounselingsolutions.org;
        index    index.php;

        location / 
        {   
            index       index.php; 
            try_files $uri $uri/ /index.php;
        }   


        location ~\\.php$
        {   
            include             /etc/nginx/fastcgi_params;
            fastcgi_param       SCRIPT_FILENAME     $document_root$fastcgi_script_name;
            fastcgi_pass        php; 
            fastcgi_index       index.php;
        }   
    }
我已经试着研究过这个问题,但我读到的所有其他信息都表明该插件与Nginx兼容,这让我相信它是我配置中的某个东西。有什么想法吗?

编辑:查看错误日志显示以下内容:

 14 2012/06/29 21:36:48 [error] 17279#0: *703 FastCGI sent in stderr: "ould not be called statically, assuming $this from incompatible context in /home/clearpointccs/public/wp-content/plugins/re    direction/models/match.php on line 68
 15 PHP Strict Standards:  Non-static method Red_Action::create() should not be called statically, assuming $this from incompatible context in /home/clearpointccs/public/wp-content/plugins/redir    ection/models/redirect.php on line 46
 16 PHP Strict Standards:  Non-static method Red_Action::available() should not be called statically, assuming $this from incompatible context in /home/clearpointccs/public/wp-content/plugins/re    direction/models/action.php on line 20" while reading response header from upstream, client: 96.228.60.10, server: www.clearpointcreditcounselingsolutions.org, request: "GET /about-us/ HTTP/    1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.clearpointcreditcounselingsolutions.org", referrer: "http://www.clearpointcreditcounselingsolutions.org/"

1 个回复
SO网友:EAMann

我立刻注意到了几件事。

首先try_files 根位置块中的参数应为:

try_files $uri $uri/ /index.php?$args;
此外,我在自己的conf文件中有这个块(使用Nginx和重定向可以很好地结合在一起),但您似乎没有找到它:

location @wp {
    rewrite ^/files(.*) /wp-includes/ms-files.php?file=$1 last;

    rewrite ^(/[^/]+)?(/wp-.*) $2 last;
    rewrite ^(/[^/]+)?(/.*.php) $2 last;

    rewrite ^/(.*)$ /index.php?q=$1 last;
}
第一次重写是针对多站点的,因此您可能需要也可能不需要它。。。

结束

相关推荐

Wp_reDirect()函数不起作用

wp_redirect($post->guid) 不工作。我怎样才能解决这个问题?这是我的代码:if(isset($_REQUEST[\'vid\']) ){ $id=$_REQUEST[\'vid\']; $post_title = \'sasa\'; $post_content =\'zxczxczxc\'; $new_post = array( \'ID\' =>