Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter, Nginx & a wordpress blog
#1

[eluser]Fabdrol[/eluser]
Hi guys,

I've got a Nginx config problem, and I was hoping that there's somebody who could help me.
I've got a public directory with a directory 'blog' in it, and in that is a wordpress blog. In the public dir there's also the index.php from CodeIgniter, and all requests are routed to that Index.php.

Now I need a directive in my config which makes sure that 'blog' is handled seperatly (e.g., not routed to public/index.php). How can I achieve that?

Thank you very much!

Code:
server {
        listen 80;
        server_name example.com www.example.com;

        access_log      /home/www/logs/access.log;
        error_log       /home/www/logs/error.log;

        root /home/www/public;

        location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
                expires max;
                break;
        }

        if ($host ~* www\.(.*)) {
                set $host_without_www $1;
                rewrite ^(.*)$ http://$host_without_www$1 permanent;
        }

        location / {
                try_files $uri @codeigniter;
                rewrite ^\/beta\/index.php/(.*)$ http://example.com/$1 permanent;
                rewrite ^\/beta\/(.*)$ http://example.com/$1 permanent;

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

        location @codeigniter {
                internal;
                root /home/www/public;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_split_path_info         ^(.+\.php)(.*)$;
                include /etc/nginx/fastcgi_config;
                include /etc/nginx/fastcgi_params;
                fastcgi_param SCRIPT_FILENAME /home/www/public/index.php;
        }

        # If directly accessing a PHP file in the public dir other than index.php
        location ~* \.php$ {
                root /home/www/public;
                try_files $uri @codeigniter;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_split_path_info         ^(.+\.php)(.*)$;
                include /etc/nginx/fastcgi_config;
                include /etc/nginx/fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
}
#2

[eluser]skunkbad[/eluser]
Unless you need to have them integrated, I think you should just use .htaccess and choose to route /blog/ to /blog/index.php.
#3

[eluser]Fabdrol[/eluser]
As I said, I'm using Nginx, which doesn't use .htaccess.
The different location blogs in the nginx configuration do about the same, containing rules for different locations. Hover, the 'blog' location doesn't work with anything I try.

Best regards,
Fabian
#4

[eluser]Pascal Kriete[/eluser]
I don't use nginx a lot, but I'm pretty sure you just need a rule before location / to catch wordpress.

Something like:
Code:
location /blog {
  try_files $uri $uri/ @wordpress;
}

location @wordpress {
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root/blog/index.php;
    fastcgi_param QUERY_STRING q=$uri&$args;
    fastcgi_pass 127.0.0.1:9000;
}

location / {
    try_files $uri @codeigniter;
. . .
#5

[eluser]Fabdrol[/eluser]
I'll give that a try, thank you very much!




Theme © iAndrew 2016 - Forum software by © MyBB