Redirect Nginx将所有目录请求重写为index.php

Redirect Nginx将所有目录请求重写为index.php,redirect,nginx,Redirect,Nginx,好吧,我在Nginx上有点n00b,我浏览了这里,无法拼凑出一个答案。这就是我得到的 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, the

好吧,我在Nginx上有点n00b,我浏览了这里,无法拼凑出一个答案。这就是我得到的

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一起使用dojumps文件夹中的这个简单的.htaccess

RewriteRule ^(.*)$ index.php/$1 [L]
但是,我在错误日志中得到一个nginx错误

/usr/share/nginx/www/dojump/index.php/cnn.com" failed (20: Not a directory)
有什么帮助吗


谢谢

尝试将url作为GET参数传递

rewrite ^/dojump/(.*)$ /dojump/index.php?url=$1 break;
很多类似的问题:Nginx有一个专门针对Wordpress的页面: