Want more timely Centmin Mod News Updates?
Become a Member

Wordpress Nginx rewrite rules - Robot.txt / sitemap.xml

Discussion in 'Blogs & CMS usage' started by ZcatK, Jul 3, 2017.

  1. ZcatK

    ZcatK New Member

    7
    2
    3
    Jul 3, 2017
    Ratings:
    +2
    Local Time:
    5:11 PM
    1.13.2
    10
    First - apologies if I am simply overlooking how to add the necessary rewrite rules. I have searched this forum in depth and Google and have only found guidance that used conf paths that are different from what Centminmod created. I also looked through all paths that Centminmod created and am lost/frustrated. I was going to create a rewrite conf and then point to it in the vhost, but I am not sure if that is a practical/working solution.

    If anyone has a better solution to create the sitemap of my site than using a plugin with rewrite rules, then I am all ears. Love the speed and flexibility of Centminmod and just have these final modifications to make. Thanks in advance!
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,784
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    12:11 AM
    Nginx 1.13.x
    MariaDB 5.5
    Last edited: Jul 3, 2017
  3. ZcatK

    ZcatK New Member

    7
    2
    3
    Jul 3, 2017
    Ratings:
    +2
    Local Time:
    5:11 PM
    1.13.2
    10
    Correct. I have always used the Google XML Sitemap plugin. I am able to navigate to sitemap.xml but it then has an html sitemap that returns a 404. Plugin says:

    Since you are using Nginx as your web-server, please configure the following rewrite rules in case you get 404 Not Found errors for your sitemap:

    rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;

    rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;

    rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;

    rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;

    I will give Yoast XML a shot.
     
  4. ZcatK

    ZcatK New Member

    7
    2
    3
    Jul 3, 2017
    Ratings:
    +2
    Local Time:
    5:11 PM
    1.13.2
    10
    Same issue with Wordpress virtual Robots.txt (404).
     
  5. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,784
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    12:11 AM
    Nginx 1.13.x
    MariaDB 5.5
    You using Nginx rewrite rules which have urls/links with .html extensions

    Centmin Mod default static files include file at /usr/local/nginx/conf/staticfiles.conf handles .html files via Nginx. But by using wordpress with .html extensions you tell Nginx not to serve .html files and serve via PHP-FPM (not ideal as it reduces performance if you use permalinks with .html extensions and thus use PHP-FPM to server .html files)

    If you must use .html extension permalinks, you need to comment out the .html location context from /usr/local/nginx/conf/staticfiles.conf and restart Nginx server as illustrated below with hash # in front
    Code:
        location ~* \.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$ {
            gzip_static off;
            #add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
            }
    
        location ~* \.(js)$ {
            #add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
            }
    
        location ~* \.(css)$ {
            #add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
            }
    
        #location ~* \.(html|htm|txt)$ {
            #add_header Pragma public;
            #add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            #access_log off;
            #expires 1d;
           # break;
           # }
    
        location ~* \.(eot|svg|ttf|woff)$ {
            #add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
            }
    
    You can also use SSH command shortcut below to launch nano linux text editor and edit file /usr/local/nginx/conf/staticfiles.conf
    Code:
    statfilesinc
     
    • Like Like x 1
  6. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,784
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    12:11 AM
    Nginx 1.13.x
    MariaDB 5.5
  7. ZcatK

    ZcatK New Member

    7
    2
    3
    Jul 3, 2017
    Ratings:
    +2
    Local Time:
    5:11 PM
    1.13.2
    10
    Thanks. You answered my question and more. Just moved over to yoast to serve as xml and created a robots.txt. Thanks again - blown away by Centmodmin and your passion for it. Hope I can add to this community and help in development.
     
    • Like Like x 1
  8. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,784
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    12:11 AM
    Nginx 1.13.x
    MariaDB 5.5
  9. ndha

    ndha Member

    53
    9
    8
    Sep 28, 2014
    Ratings:
    +23
    Local Time:
    9:11 PM
    Latest
    10
    Hi...
    Just use Include file in your domain nginx vhost with that config above..
    I had setup like that too with CMM and everything is fine..
    in fact some domains using YOAST and some using above config with Google Sitemap Generator Plugin by Arne Brachhold, right ???