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

时间:2011-08-12 21:02:41

标签: redirect nginx

好吧,我对Nginx有点啰嗦,而且我已经浏览了这里,无法拼凑出答案。这就是我得到的

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 bootstrap。

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)

有任何帮助吗?

由于

1 个答案:

答案 0 :(得分:3)

尝试将url作为GET参数传递。

rewrite ^/dojump/(.*)$ /dojump/index.php?url=$1 break;
相关问题