2015-09-10 63 views
1

搜索了半天也沒找到答案,謝謝你先在這裏笨在WordPress的如何配置Nginx的

這裏是我的目錄: 的WordPress在/var/projects/root 笨在/var/projects/root/codeigniter/

這裏是我的nginx服務器配置:

listen 80; 
server_name nginx.local.com; 
root /var/projects/root; 
error_log /var/projects/log/error.log warn; 
access_log /var/projects/log/access.log main; 

if ($host != 'nginx.local.com'){ 
    rewrite ^/(.*) http://nginx.local.com/$1 permanent; 
} 

location/{ 
    index index.php index.html index.html; 
} 

rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last; 
if (!-e $request_filename) { 
    rewrite ^.+?(/wp-.*) $1 last; 
    rewrite ^.+?(/.*\.php)$ $1 last; 
    rewrite^/index.php last; 
} 

location ~ \.php$ { 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    include  fastcgi_params; 
} 

location ~ /codeigniter/ { 
    if (!-e $request_filename) 
    { 
     rewrite ^/(.*)$ /index.php/$1 last; 
     break; 
    } 
} 

location /codeigniter { 
    try_files $uri $uri/ /codeigniter/index.php?$query_string; 
} 

我已經嘗試了很多方法,該笨已經成爲原代碼,現在只有http://nginx.local.com/codeigniterhttp://nginx.local.com/codeigniter/index.php可以訪問(歡迎頁)

以下頁面是404 Not Found http://nginx.local.com/index.php/codeigniter/welcome/index http://nginx.local.com/codeigniter/welcome/index http://nginx.local.com/index.php/codeigniter/welcome/test

回答

1

我嘗試瞭解決方案。

server { 
    listen 80; 
    server_name nginx.local.com; 
    root /var/projects/root; 
    error_log /var/projects/log/error.log warn; 
    access_log /var/projects/log/access.log main; 

    if ($host != 'nginx.local.com'){ 
     rewrite ^/(.*) http://nginx.local.com/$1 permanent; 
    } 

    location/{ 
     index index.php index.html index.html; 
     if (!-e $request_filename) { 
      rewrite ^.+?(/wp-.*) $1 last; 
      rewrite ^.+?(/.*\.php)$ $1 last; 
      rewrite^/index.php last; 
     } 
     rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last; 
    } 

    #Here is codeignter path 
    location ~ /codeignter { 
     try_files $uri $uri/ /index.php?$query_string; 
     location ~ \.php($|/) { 
      fastcgi_pass 127.0.0.1:9000; 
      fastcgi_index evindex.php; 
      fastcgi_split_path_info ^(.+\.php)(.*)$; 
      fastcgi_param PATH_INFO $fastcgi_path_info; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      include  fastcgi_params; 
     } 
    } 

    location ~ \.php$ { 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     include  fastcgi_params; 
    } 

}