2011-08-12 38 views
3

好吧,我在Nginx上是n00b,我瀏覽過這裏,無法拼湊出答案。因此,這裏是我得到Nginx重寫所有的目錄請求到index.php

server { 
root /usr/share/nginx/www; 
index index.php index.html index.htm; 

# Make site accessible from http://localhost/ 
server_name localhost; 

location/{ 
    # First attempt to serve request as file, then 
    # as directory, then fall back to index.html 


     if (-f $request_filename) { 
      expires 30d; 
      break; 
     } 
     if (!-e $request_filename) { 
      rewrite ^(.+)$ /index.php?q=$1 last; 
     } 
} 

location /dojump { 
    rewrite ^/dojump/(.*)$ /dojump/index.php/$1 break; 
} 


# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
# 
location ~ \.php(.*)$ { 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_index index.php; 
    include fastcgi_params; 
} 

這是一個WordPress安裝的第一個位置塊應該通過所有的文件請求到WordPress的引導。

location /dojump塊應該用於出站重定向腳本。我想趕上參數並將其傳遞給index.php的腳本

像/dojump/cnn.com 到/dojump/index.php/cnn.com

它的工作原理與Apache這個簡單的的.htaccess線dojumps文件夾內

RewriteRule ^(.*)$ index.php/$1 [L] 

不過,我得到的錯誤日誌

/usr/share/nginx/www/dojump/index.php/cnn.com" failed (20: Not a directory) 
Nginx上錯誤

任何幫助?

謝謝

+2

很多類似的問題:http://stackoverflow.com/questions/5920081/ http://stackoverflow.com/questions/3255446/ Nginx已經致力於WordPress的頁面:http://wiki.nginx .org/Wordpress –

回答

3

嘗試將url作爲GET參數傳遞。

rewrite ^/dojump/(.*)$ /dojump/index.php?url=$1 break; 
+0

它工作完美,平穩,謝謝matzahboy – Rafa

相關問題