Nginx configuration for a wordpress blog in a subfolder of magento root

admin

Administrator
Staff member
I have installed a Magento extension to have a wordpress blog integrated with Magento.
Basically, the WP is in a subdirectory of the Magento root. I want to create multiple sites with subdirectories but I can't make it work due to the nginx configuration.

Wordpress is in his /wp subdirectory (<a href="http://example.com/wp/wp-admin/" rel="nofollow">http://example.com/wp/wp-admin/</a>) and the others sites are accessible from <a href="http://example.com/wp/ca/wp-admin/" rel="nofollow">http://example.com/wp/ca/wp-admin/</a> and <a href="http://example.com/wp/en/wp-admin/" rel="nofollow">http://example.com/wp/en/wp-admin/</a>

Here is whats I got so far :

Code:
server
{
    server_name dev.example.com;
    access_log /var/log/nginx/example.access.log;-
    error_log /var/log/nginx/example.error.log;
    root /var/www/example;

    location ^~ /wp {
        index index.php index.html index.htm;
        try_files $uri $uri/ /wp/index.php?q=$uri&amp;$args;

        # Multisite
        if (!-e $request_filename) {
            rewrite /wp-admin$ $scheme://$host$uri/ permanent;         
            rewrite ^/wp(/[^/]+)?(/wp-.*) /wp$2 last;      
            rewrite ^/wp(/[^/]+)?(/.*\.php)$ /wp$2 last;
        }

        location ~ \.php$ {
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            fastcgi_pass 127.0.0.1:9000;
        }   
    }  

    set             $mage_developer true;
    set             $mage_code es; 
    set             $mage_type store;
    include         snippets.d/magento-site;-
}

and in snippets.d/magento-site :

Code:
# Serve static pages directly,
# otherwise pass the URI to Magento's front handler
location / {
    index       index.php;
    try_files   $uri $uri/ @handler;
    expires     30d;-
}

# Disable .htaccess and other hidden files
location  /. {
    return 404;
}

# Allow admins only to view export folder
location /var/export/ {
    auth_basic               "Restricted";
    auth_basic_user_file     htpasswd;
    autoindex                on; 
}

# These locations would be hidden by .htaccess normally
location /app/                { deny all; }
location /includes/           { deny all; }
location /lib/                { deny all; }
location /media/downloadable/ { deny all; }
location /pkginfo/            { deny all; }
location /report/config.xml   { deny all; }
location /var/                { deny all; }

# Magento uses a common front handler
location @handler {
    rewrite / /index.php;
}

# Forward paths like /js/index.php/x.js to relevant handler
location ~ .php/ {
    rewrite ^(.*.php)/ $1 last;
}

# Execute PHP scripts
location ~ .php$ {

    # Catch 404s that try_files miss
    if (!-e $request_filename) { rewrite / /index.php last; }

    expires        off;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
    fastcgi_param  MAGE_RUN_CODE $mage_code;
    fastcgi_param  MAGE_RUN_TYPE $mage_type;
    fastcgi_ignore_client_abort on;
    fastcgi_read_timeout 900s; # 15 minutes
}

Thanks for your help.