2012-09-19 58 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