没有WordPress插件能够生成站点地图 [英] No WordPress plugin able to generate a sitemap

查看:155
本文介绍了没有WordPress插件能够生成站点地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前一段时间,我设法在VPS上安装Virtualmin,并且当前正在运行WordPress.我也在使用Nginx.

A while ago I managed to install Virtualmin on my VPS and am currently running WordPress. I'm also using Nginx.

从备份中恢复博客后,我就可以启动它并开始运行,并开始设置插件.

After restoring my blog back from the backups I made, I was able to get it up and running and started to set up the plugins.

我最初使用yoast,并尝试生成Sitemat,但是它不起作用-我一直收到404错误.我什至使用FTP进行了检查,但未找到文件.因此,我在网上查找了解决方案,并尝试了所有解决方案,刷新了永久链接,添加了htaccess规则,向nginx.conf中添加了重写规则,清除了缓存等等.但没有任何效果.

I initially used yoast, and tried to generate a sitemat but it didn't work - I kept getting a 404 error. I even checked using FTP and no file was found. So I looked up for solutions online and tried them all, refreshing permalinks, adding htaccess rules, adding rewrite rules to nginx.conf, purging cache and more. But nothing worked.

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

I also even tried uploading a dummy sitemap_index.xml file and refreshed the sitemap setting but it was never read nor updated.

因此,我决定也尝试其他插件,例如多合一SEO","Jetpack","Google"站点地图,但遗憾的是,它们都无法创建站点地图.

So I decided to try other plugins too, All-in-One SEO, Jetpack, Google sitemaps, but sadly none of them were also able to create a sitemap.

这是我的.htaccess文件

This is my .htaccess file

# 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)

And this is my nginx config (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;
}

}

推荐答案

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

I have a single wordpress installation
I use XML Sitemap Generator for WordPress 4.1.0 plugin.
I also had an issue with sitemap giving 404.
Here's what solved it for me:

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 ~内部为我解决了这个问题.

Putting the sitemap rewrite inside location ~ solved the issue for me.

这篇关于没有WordPress插件能够生成站点地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆