没有WordPress插件能够生成站点地图

时间:2017-04-05 10:26:32

标签: wordpress nginx sitemap virtualmin yoast

前段时间我设法在我的VPS上安装Virtualmin,目前正在运行WordPress。我也在使用Nginx。

从我制作的备份中恢复我的博客后,我能够启动并运行并开始设置插件。

我最初使用yoast,并试图生成一个sitemat但它没有工作 - 我一直收到404错误。我甚至使用FTP检查,没有找到文件。所以我在网上查找解决方案并尝试了所有解决方案,刷新永久链接,添加htaccess规则,向nginx.conf添加重写规则,清除缓存等等。但没有任何效果。

我甚至尝试上传虚拟的sitemap_index.xml文件并刷新了站点地图设置,但它从未被读取或更新过。

所以我决定尝试其他插件,All-in-One SEO,Jetpack,Google站点地图,但遗憾的是他们中没有一个也能够创建站点地图。

这是我的.htaccess文件

# WordPress SEO - XML Sitemap Rewrite Fix
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^sitemap_index.xml$ /index.php?sitemap=1 [L]
RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 [L]
</IfModule>
# END WordPress SEO - XML Sitemap Rewrite Fix

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

这是我的nginx配置(ikigainetwork.moe.conf)

server {
    server_name ikigainetwork.moe www.ikigainetwork.moe;
    listen 81.4.104.56;
    root /home/ikigainetwork/public_html;
    index index.html index.htm index.php;
    access_log /var/log/virtualmin/ikigainetwork.moe_access_log;
    error_log /var/log/virtualmin/ikigainetwork.moe_error_log;
    fastcgi_param GATEWAY_INTERFACE CGI/1.1;
    fastcgi_param SERVER_SOFTWARE nginx;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    fastcgi_param SCRIPT_FILENAME /home/ikigainetwork/public_html$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_param REQUEST_URI $request_uri;
    fastcgi_param DOCUMENT_URI $document_uri;
    fastcgi_param DOCUMENT_ROOT /home/ikigainetwork/public_html;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    fastcgi_param REMOTE_ADDR $remote_addr;
    fastcgi_param REMOTE_PORT $remote_port;
    fastcgi_param SERVER_ADDR $server_addr;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_NAME $server_name;
    fastcgi_param HTTPS $https;
    location / {
                try_files $uri $uri/ /index.php?$args; 
    }
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/php-nginx/14911244012458.sock/socket;
    }
location ~* \.(txt|xml|js)$ {
    expires 8d;
}

location ~* \.(css)$ {
    expires 8d;
}

location ~* \.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|mp4|m4v|ogg|webm|aac)$ {
    expires 8d;
}

location ~* \.(jpg|jpeg|png|gif|swf|webp)$ {
    expires 8d;
}
    listen 81.4.104.56:443 default ssl;
    ssl_certificate /home/ikigainetwork/ssl.cert;
    ssl_certificate_key /home/ikigainetwork/ssl.key;

#Yoast sitemap
location ~ ([^/]*)sitemap(.*)\.x(m|s)l$ {
    rewrite ^/sitemap\.xml$ /sitemap_index.xml permanent;
        rewrite ^/([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 last;
    rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
    rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;

        ## following lines are options. Needed for wordpress-seo addons
        rewrite ^/news_sitemap\.xml$ /index.php?sitemap=wpseo_news last;
    rewrite ^/locations\.kml$ /index.php?sitemap=wpseo_local_kml last;
    rewrite ^/geo_sitemap\.xml$ /index.php?sitemap=wpseo_local last;
    rewrite ^/video-sitemap\.xsl$ /index.php?xsl=video last;

    access_log off;
}

}

1 个答案:

答案 0 :(得分:0)

我只有一个wordpress安装
我使用XML Sitemap Generator for WordPress 4.1.0插件。
我也遇到了站点地图提供404的问题。
这是为我解决的问题:

location / {
    try_files $uri $uri/ /index.php?$args;

    location ~ ([^/]*)sitemap(.*).x(m|s)l$ {
        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;
        }
}

将站点地图重写放在location ~内为我解决了这个问题。