2012-09-19 56 views
1

出于某种原因,我总是无法让Wordpress在nginx上工作。当wordpress不在主目录中时wordpress url重写在nginx

我有我的Wordpress安装在文件夹“网站”(在public_html中)。 这是我的nginx的配置:

server { 
    server_name www.wouterds.be wouterds.be; 
    access_log /srv/www/www.wouterds.be/logs/access.log; 
    error_log /srv/www/www.wouterds.be/logs/error.log; 

    location/{ 
     root /srv/www/www.wouterds.be/public_html; 
     index index.php index.html index.htm; 
     try_files $uri $uri/ /site/index.php?$args; 
     autoindex on; 
    } 

    location ~ \.php$ { 
     include /etc/nginx/fastcgi_params; 
     fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME /srv/www/www.wouterds.be/public_html$fastcgi_script_name; 
    } 
} 

当我访问我的网站http://wouterds.be/我得到的只是目录索引。 当我访问http://wouterds.be/blog/我得到正确的页面,一切正常。 但我不知道如何让它在基础网址上工作。

任何人谁可以帮我一下吗?我当然不是nginx专家,经过4个小时Google,我决定在这里尝试一下。

回答

0

只是改变:

root /srv/www/www.wouterds.be/public_html; 

root /srv/www/www.wouterds.be/public_html/site; 

假设wordpress的index.php文件里面site文件夹。

还移动root线外&以上location块。

你可以试试...

server { 
    #other stuff 

    root /srv/www/www.wouterds.be/public_html/site ; 

    location/{ 
     root /srv/www/www.wouterds.be/public_html; 
     index index.php index.html index.htm; 
     try_files $uri $uri/ /site/index.php?$args; 
     autoindex on; 
    } 

    #other stuff 
} 
+0

我得到一个重定向循环当我尝试这一点。 – Ryan