Support » Fixing WordPress » Nginx (Magento site) permalinks issue

  • Hi

    We have a WordPress site running and installed within /info under a Magento e-commerce site.

    Unfortunately, whatever we try, we only see 404 errors for any page we want to run at the top level i.e. /info/wordpress-page-here/.

    The blog portion, which sites within /info/blog works fine, so /info/blog/wordpress-post-here/ is okay.

    In fact anything under a subfolder will work, as long as a rule is manually entered into the config and Nginx restarted.

    So ideally it’d be great if the WP users could setup any %postname% to run directly within /info and for it to just work.

    If anyone has any ideas it would be very much appreciated.

    Kind regards
    PG

    WordPress URL is set as http://XXX.com/info
    Permalinks are set as /info/%postname%

    Part of our Nginx config is as follows:

    location /info/blog {
            alias /home/blog_master/bestecoshop.com/;
            index index.php;
            try_files $uri $uri/ /info/index.php?$args;
        }
    
        location ~ ^/info/blog/(.*\.php)$ {
            ## Catch 404s that try_files miss
            if (!-e $request_filename) { rewrite / /info/index.php last; }
            alias /home/blog_master/bestecoshop.com/$1;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include /etc/nginx/fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $request_filename;
        }
    
        location /info {
    
            # WordPress sitemap
            # rewrite ^/info/sitemap_index\.xml$ /info/index.php?sitemap=1 last;
            # rewrite ^/info/([^/]+?)-sitemap([0-9]+)?\.xml$ /info/index.php?sitemap=$1&sitemap_n=$2 last;
    
            alias /home/blog_master/bestecoshop.com/;
            index index.php;
            try_files $uri $uri/ /info/index.php?$args;
            rewrite ^/info/?$ /info/blog/ redirect;
    
        }
    
        location ~ ^/info/(.*\.php)$ {
            ## Catch 404s that try_files miss
            if (!-e $request_filename) { rewrite / /info/index.php last; }
            alias /home/blog_master/bestecoshop.com/$1;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include /etc/nginx/fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $request_filename;
        }

Viewing 3 replies - 1 through 3 (of 3 total)
  • As far as I can tell, you shouldn’t have the permalinks set up as /info/%postname%. WordPress knows that everything is in the /info/ folder becuse you’ve got that in your base URL, so adding it in there as well will give you a double-folder situation. Your links would like like http://www.site.com/info/info/postname

    Thread Starter Pendle_Gazza

    (@pendle_gazza)

    Hi

    Many thanks for your reply.

    Sorry, the permalinks are just set up as ‘%postname%’ in the custom section, with the /info/ being automatically prefixed, so it’s not that it is doubling up.

    I can, for example, try the following:

    location /info {
            alias /home/blog_master/site/;
            index index.php;
            rewrite ^/info/(.*)+$ /info/index.php$1;
        }

    and that will mean the permalinks work, but everything else around it falls over (i.e. CSS links, admin panel links and anything referenced within /info), so somehow I need to find a config which will see everything WordPress work in complete harmony, permalink and admin. Sadly it’s still proving elusive! :-s

    Thanks again

    What is the actual URL that’s being output in your pages HTML code for the CSS and JS file links? If it helps you can post a link to your site os that we can see what’s going on.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Nginx (Magento site) permalinks issue’ is closed to new replies.