{"id":38,"date":"2026-08-06T11:18:24","date_gmt":"2026-08-06T03:18:24","guid":{"rendered":"https:\/\/www.iforz.cn\/?p=38"},"modified":"2026-08-06T11:18:24","modified_gmt":"2026-08-06T03:18:24","slug":"wordpress-robots-sitemap-404-nginx-try-files","status":"publish","type":"post","link":"https:\/\/www.iforz.cn\/index.php\/2026\/08\/06\/wordpress-robots-sitemap-404-nginx-try-files\/","title":{"rendered":"WordPress \u7684 robots.txt \u548c wp-sitemap.xml \u4e3a\u4ec0\u4e48\u4f1a\u540c\u65f6 404"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u7ed3\u8bba\u5148\u884c<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728<strong>\u542f\u7528\u4e86\u975e\u7a7a\u56fa\u5b9a\u94fe\u63a5\u3001WordPress \u524d\u53f0 Home URL \u4f4d\u4e8e\u57df\u540d\u6839\u8def\u5f84\u3001\u7ad9\u70b9\u5728 WordPress \u4e2d\u88ab\u6807\u8bb0\u4e3a\u516c\u5f00\u53ef\u7d22\u5f15<\/strong>\u7684\u524d\u63d0\u4e0b\uff0c\u5982\u679c <code>\/robots.txt<\/code> \u548c <code>\/wp-sitemap.xml<\/code> \u540c\u65f6\u8fd4\u56de\u7684\u662f Nginx \u98ce\u683c 404\uff0c\u800c\u6839 URI \u548c PHP \u53c8\u6709\u53ef\u7528\u5904\u7406\u8def\u5f84\uff0c\u5148\u68c0\u67e5 Nginx \u6709\u6ca1\u6709\u628a\u4e0d\u5b58\u5728\u7684\u865a\u62df\u8def\u5f84\u4ea4\u7ed9 WordPress \u7684 <code>index.php<\/code>\u3002\u9519\u8bef\u9875\u5916\u89c2\u53ea\u662f\u4e00\u6761\u7ebf\u7d22\uff0c\u4e0d\u80fd\u5355\u72ec\u8bc1\u660e\u6545\u969c\u5c42\u7ea7\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u6b21\u6545\u969c\u4e0d\u662f\u5c11\u4e86\u4e24\u4e2a\u6587\u4ef6\uff0c\u800c\u662f\u5c11\u4e86\u4e00\u6b21\u8bf7\u6c42\u4ea4\u63a5\u3002\u4e24\u4e2a URL \u90fd\u7531 WordPress \u5728\u8fd0\u884c\u65f6\u751f\u6210\uff1a\u6838\u5fc3\u91cd\u5199\u89c4\u5219\u628a <code>robots.txt<\/code> \u6620\u5c04\u5230 <code>index.php?robots=1<\/code>\uff0c\u628a <code>wp-sitemap.xml<\/code> \u6620\u5c04\u5230 <code>index.php?sitemap=index<\/code>\u3002\u8bf7\u6c42\u82e5\u88ab Nginx \u63d0\u524d\u4ee5 404 \u7ed3\u675f\uff0cWordPress \u8fde\u51fa\u573a\u7684\u673a\u4f1a\u90fd\u6ca1\u6709\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u7ec8\u4fee\u590d\u53ea\u6709\u4e00\u6761\u6838\u5fc3\u903b\u8f91\uff1a\u5b9e\u4f53\u6587\u4ef6\u548c\u76ee\u5f55\u4f18\u5148\uff0c\u5176\u4f59\u524d\u53f0\u8bf7\u6c42\u8fdb\u5165 <code>index.php<\/code>\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-nginx\">location \/ {\n    try_files $uri $uri\/ \/index.php?$args;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f46\u4e0d\u8981\u628a\u8fd9\u4e00\u6bb5\u4e0d\u770b\u4e0a\u4e0b\u6587\u5730\u7c98\u8fdb\u751f\u4ea7\u914d\u7f6e\u3002\u4e0b\u9762\u5148\u7528\u56db\u4e2a\u8bf7\u6c42\u7684\u72b6\u6001\u7801\u3001Content-Type\u3001\u54cd\u5e94\u94fe\u548c\u6b63\u6587\uff0c\u5224\u65ad\u6545\u969c\u7a76\u7adf\u5728 Nginx\u3001WordPress\uff0c\u8fd8\u662f\u7ad9\u70b9\u53ef\u89c1\u6027\u548c\u63d2\u4ef6\u5c42\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u73b0\u573a\uff1a\u4e24\u4e2a SEO \u5165\u53e3\u4e00\u8d77\u5931\u6548<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u662f\u672c\u7ad9\u5b8c\u6210<a href=\"https:\/\/www.iforz.cn\/index.php\/2026\/08\/05\/recover-expired-letsencrypt-nginx-wordpress-zero-downtime\/\">\u8bc1\u4e66\u6062\u590d\u4e0e\u4e25\u683c HTTPS \u9a8c\u6536<\/a>\u540e\u53d1\u73b0\u7684\u7b2c\u4e8c\u4e2a\u95ee\u9898\u3002\u73af\u5883\u662f Nginx\u3001PHP-FPM \u548c WordPress 7.0.2\uff0c\u9996\u9875\u80fd\u6253\u5f00\uff0c\u5e26 <code>\/index.php\/<\/code> \u7684\u5386\u53f2\u6587\u7ae0\u4e5f\u80fd\u8bbf\u95ee\uff0c\u4f46\u4e24\u4e2a\u57fa\u7840\u5165\u53e3\u5f02\u5e38\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>\/robots.txt<\/code> \u8fd4\u56de 404\uff1b<\/li><li><code>\/wp-sitemap.xml<\/code> \u8fd4\u56de 404\uff1b<\/li><li>\u5f53\u5929\u4fee\u590d\u524d\u7684\u8bbf\u95ee\u65e5\u5fd7\u5206\u522b\u8bb0\u5f55\u5230 4 \u6b21\u548c 9 \u6b21 404\uff1b<\/li><li>PHP-FPM \u6ca1\u6709\u5bf9\u5e94\u62a5\u9519\uff0c\u7ad9\u70b9\u4e5f\u6ca1\u6709 5xx\u3002<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u7ec4\u73b0\u8c61\u5f88\u5173\u952e\u3002\u9996\u9875\u80fd\u5f00\uff0c\u53ea\u80fd\u8bf4\u660e\u6839 URI \u6709\u53ef\u7528\u5904\u7406\u8def\u5f84\uff0c\u5185\u5bb9\u53ef\u80fd\u6765\u81ea PHP\u3001\u7f13\u5b58\u6216\u4ee3\u7406\uff1b\u5e26 <code>index.php<\/code> \u7684\u5730\u5740\u80fd\u5f00\uff0c\u53ea\u80fd\u8bf4\u660e\u8fd9\u6761 PHP \u8def\u5f84\u53ef\u7528\u3002\u5b83\u4eec\u90fd\u4e0d\u80fd\u8bc1\u660e\u201c\u4e0d\u5b58\u5728\u7684\u524d\u53f0\u8def\u5f84\u201d\u5df2\u7ecf\u88ab\u8f6c\u4ea4\u7ed9 WordPress\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e3a\u4ec0\u4e48\u78c1\u76d8\u4e0a\u627e\u4e0d\u5230\u8fd9\u4e24\u4e2a\u6587\u4ef6<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">WordPress \u9ed8\u8ba4\u4e0d\u4f1a\u5728\u7f51\u7ad9\u6839\u76ee\u5f55\u81ea\u52a8\u521b\u5efa\u4e00\u4efd\u5b9e\u4f53 <code>robots.txt<\/code>\u3002\u6838\u5fc3\u7684 <a href=\"https:\/\/developer.wordpress.org\/reference\/classes\/wp_rewrite\/rewrite_rules\/\">@@IFORZINLINE1@@<\/a> \u4f1a\u5728\u9002\u7528\u6761\u4ef6\u4e0b\u6ce8\u518c <code>robots\\.txt$<\/code>\uff0c\u518d\u7531 <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/do_robots\/\">@@IFORZINLINE3@@<\/a> \u4ee5 <code>text\/plain<\/code> \u52a8\u6001\u8f93\u51fa\u5185\u5bb9\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6838\u5fc3 XML sitemap \u4e5f\u662f\u540c\u6837\u601d\u8def\u3002<a href=\"https:\/\/developer.wordpress.org\/reference\/classes\/wp_sitemaps\/register_rewrites\/\">@@IFORZINLINE0@@<\/a> \u6ce8\u518c\u7d22\u5f15\u3001\u5b50 sitemap \u548c XSL \u8def\u7531\uff1b\u9ed8\u8ba4\u7d22\u5f15\u5165\u53e3\u662f <code>\/wp-sitemap.xml<\/code>\uff0c\u4e0d\u662f\u5f88\u591a SEO \u63d2\u4ef6\u4f7f\u7528\u7684 <code>\/sitemap_index.xml<\/code>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u56e0\u6b64\uff0c\u4e0b\u9762\u8fd9\u6837\u7684\u914d\u7f6e\u4f1a\u628a\u5b83\u4eec\u4e00\u8d77\u622a\u65ad\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-nginx\">location \/ {\n    try_files $uri $uri\/ =404;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Nginx \u4f1a\u5148\u68c0\u67e5\u78c1\u76d8\u4e0a\u7684\u540c\u540d\u6587\u4ef6\u548c\u76ee\u5f55\u3002\u4e24\u8005\u90fd\u4e0d\u5b58\u5728\u65f6\uff0c\u6700\u540e\u53c2\u6570 <code>=404<\/code> \u4f1a\u76f4\u63a5\u7ed3\u675f\u8bf7\u6c42\u3002\u6839\u636e <a href=\"https:\/\/nginx.org\/en\/docs\/http\/ngx_http_core_module.html#try_files\">Nginx @@IFORZINLINE1@@ \u5b98\u65b9\u8bf4\u660e<\/a>\uff0c\u6700\u540e\u53c2\u6570\u5199\u6210\u666e\u901a URI \u6216\u547d\u540d location \u65f6\u624d\u4f1a\u5185\u90e8\u8df3\u8f6c\uff1b\u8981\u628a\u8bf7\u6c42\u4ea4\u7ed9 WordPress\uff0c\u5e94\u6307\u5411\u771f\u5b9e\u7684 <code>index.php<\/code> \u6216\u7ad9\u70b9\u5b9e\u9645\u4f7f\u7528\u7684 WordPress \u547d\u540d location\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5148\u505a\u56db\u4e2a\u8bf7\u6c42\uff0c\u4e0d\u8981\u5148\u6539\u914d\u7f6e<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u628a\u57df\u540d\u6362\u6210\u81ea\u5df1\u7684\uff0c\u5206\u522b\u6d4b\u8bd5\u6f02\u4eae\u8def\u5f84\u548c WordPress \u67e5\u8be2\u5f62\u5f0f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-bash\">site=&#039;https:\/\/example.com&#039;\n\ncurl -sS --connect-timeout 5 --max-time 15 -D - &quot;$site\/robots.txt&quot;\ncurl -sS --connect-timeout 5 --max-time 15 -D - &quot;$site\/wp-sitemap.xml&quot;\n\ncurl -sS --connect-timeout 5 --max-time 15 -D - &quot;$site\/?robots=1&quot;\ncurl -sS --connect-timeout 5 --max-time 15 -D - &quot;$site\/?sitemap=index&quot;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u7ed3\u679c\u53ef\u4ee5\u8fd9\u6837\u8bfb\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong><code>\/?robots=1<\/code> \u4e3a 200\u3001Content-Type \u4ee5 <code>text\/plain<\/code> \u5f00\u5934\uff0c\u6b63\u6587\u662f robots \u89c4\u5219\uff0c\u800c\u6f02\u4eae\u8def\u5f84 404<\/strong>\uff1aWordPress \u5df2\u80fd\u52a8\u6001\u8f93\u51fa robots\uff0c\u91cd\u70b9\u67e5 Nginx \u5bf9 <code>\/robots.txt<\/code> \u7684\u8def\u5f84\u4ea4\u63a5\u3002<\/li><li><strong><code>\/?sitemap=index<\/code> \u76f4\u63a5\u8fd4\u56de 200 XML<\/strong>\uff1a\u518d\u786e\u8ba4 Content-Type \u4ee5 <code>application\/xml<\/code> \u5f00\u5934\u4e14\u6b63\u6587\u53ef\u89e3\u6790\uff0c\u624d\u80fd\u8bc1\u660e\u6838\u5fc3\u751f\u6210\u4e86 sitemap\u3002<\/li><li><strong>sitemap \u67e5\u8be2\u8fd4\u56de 301 \u5230 <code>\/wp-sitemap.xml<\/code>\uff0c\u4e14\u54cd\u5e94\u542b <code>X-Redirect-By: WordPress<\/code><\/strong>\uff1a\u8fd9\u8868\u660e WordPress \u5df2 bootstrap \u5e76\u8bc6\u522b\u67e5\u8be2\uff0c\u4f46\u4e0d\u80fd\u5355\u72ec\u8bc1\u660e sitemap \u6b63\u6587\u6b63\u5e38\uff1b\u5355\u51ed 301 \u548c Location \u4e0d\u80fd\u4f5c\u6b64\u5224\u65ad\uff0c\u4e5f\u4e0d\u8981\u8ddf\u968f\u8df3\u8f6c\u540e\u518d\u628a\u540c\u4e00\u4e2a 404 \u5f53\u6210\u72ec\u7acb\u8bc1\u636e\u3002<\/li><li><strong>sitemap \u67e5\u8be2\u4ecd\u4e3a 404 \u6216\u6b63\u6587\u4e0d\u662f XML<\/strong>\uff1a\u68c0\u67e5\u201c\u5efa\u8bae\u641c\u7d22\u5f15\u64ce\u4e0d\u7d22\u5f15\u672c\u7ad9\u201d\u3001<code>wp_sitemaps_enabled<\/code> \u8fc7\u6ee4\u5668\u6216 SEO \u63d2\u4ef6\u3002WordPress \u7684 <a href=\"https:\/\/developer.wordpress.org\/reference\/classes\/wp_sitemaps\/sitemaps_enabled\/\">@@IFORZINLINE1@@<\/a> \u9ed8\u8ba4\u8bfb\u53d6\u7ad9\u70b9\u516c\u5f00\u72b6\u6001\uff0c\u7981\u7528\u540e\u6838\u5fc3\u4f1a\u6709\u610f\u8fd4\u56de 404\u3002<\/li><li><strong>\u56db\u4e2a\u8bf7\u6c42\u90fd\u5931\u8d25<\/strong>\uff1a\u4e0d\u8981\u76f4\u63a5\u5957\u7528\u901a\u7528 <code>location \/<\/code>\uff1b\u7ee7\u7eed\u68c0\u67e5 PHP location\u3001FastCGI \u67e5\u8be2\u53c2\u6570\u3001WordPress bootstrap\u3001\u63d2\u4ef6\u548c\u9519\u8bef\u65e5\u5fd7\u3002<\/li><li><strong>\u672a\u542f\u7528\u6f02\u4eae\u56fa\u5b9a\u94fe\u63a5<\/strong>\uff1aWordPress \u6838\u5fc3\u7684 <a href=\"https:\/\/developer.wordpress.org\/reference\/classes\/wp_sitemaps_index\/get_index_url\/\">@@IFORZINLINE0@@<\/a> \u8fd4\u56de <code>\/?sitemap=index<\/code>\uff0c\u4e0d\u80fd\u770b\u5230 <code>\/wp-sitemap.xml<\/code> 404 \u5c31\u76f4\u63a5\u5224\u5b9a\u8def\u7531\u574f\u4e86\u3002<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c PHP \u7f3a\u5c11 SimpleXML\uff0cWordPress \u6838\u5fc3 sitemap \u4f1a\u8fd4\u56de 501\uff1b\u90a3\u4e5f\u4e0d\u662f\u672c\u6587\u8ba8\u8bba\u7684 rewrite 404\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e00\u6b65\u7684\u4ef7\u503c\u662f\u628a\u95ee\u9898\u5206\u5c42\u3002\u53cd\u590d\u4fdd\u5b58\u56fa\u5b9a\u94fe\u63a5\u3001\u6e05\u7f13\u5b58\u6216\u521b\u5efa\u5b9e\u4f53\u6587\u4ef6\uff0c\u90fd\u4e0d\u80fd\u66ff\u4ee3\u5206\u5c42\u8bca\u65ad\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u672c\u6b21\u4fee\u590d\uff1a\u8ba9\u865a\u62df URL \u8fdb\u5165\u524d\u7aef\u63a7\u5236\u5668<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5148\u627e\u5230<strong>\u5b9e\u9645\u88ab\u76ee\u6807\u865a\u62df\u4e3b\u673a include \u7684\u914d\u7f6e\u6587\u4ef6<\/strong>\u3002\u9762\u677f\u73af\u5883\u7ecf\u5e38\u628a\u4e3b\u914d\u7f6e\u3001\u7ad9\u70b9\u914d\u7f6e\u3001rewrite \u548c\u4ee3\u7406\u89c4\u5219\u62c6\u5f00\uff1b\u6539\u5230\u4e00\u4efd\u6ca1\u6709\u88ab\u52a0\u8f7d\u7684\u793a\u4f8b\u6587\u4ef6\uff0c<code>nginx -t<\/code> \u4e5f\u53ef\u80fd\u7167\u6837\u6210\u529f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u786e\u8ba4\u76ee\u6807\u540e\uff0c\u5148\u6392\u67e5\u662f\u5426\u5df2\u6709 <code>location = \/robots.txt<\/code>\uff0c\u662f\u5426\u6709\u5339\u914d <code>.xml<\/code>\u3001<code>.xsl<\/code>\u3001<code>.txt<\/code> \u7684\u6b63\u5219\u9759\u6001\u5757\uff0c\u4ee5\u53ca\u662f\u5426\u5b58\u5728 <code>^~<\/code> \u524d\u7f00\u6216 sitemap \u4e13\u7528\u6b63\u5219\u3002\u7cbe\u786e location \u4f1a\u7acb\u5373\u7ed3\u675f\u5339\u914d\uff0c\u6b63\u5219 location \u4e5f\u53ef\u80fd\u8986\u76d6\u666e\u901a <code>location \/<\/code>\uff1b\u8fd9\u4e9b\u5757\u82e5\u63d0\u524d\u622a\u4f4f\u8bf7\u6c42\uff0c\u53ea\u6539\u901a\u7528 fallback \u4ecd\u4e0d\u4f1a\u751f\u6548\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6392\u9664\u4f18\u5148\u7ea7\u51b2\u7a81\u540e\u5148\u5907\u4efd\uff0c\u518d\u4fee\u6539\u73b0\u6709\u7684 <code>location \/<\/code>\uff0c\u6216\u8005\u5728\u786e\u5b9e\u6ca1\u6709\u8be5\u5757\u65f6\u8865\u4e0a\u3002\u4e0d\u8981\u5236\u9020\u4e24\u4e2a\u91cd\u590d\u7684 <code>location \/<\/code>\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-nginx\">location \/ {\n    try_files $uri $uri\/ \/index.php?$args;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e09\u6bb5\u7684\u542b\u4e49\u4f9d\u6b21\u662f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>$uri<\/code>\uff1a\u771f\u5b9e\u6587\u4ef6\u4f18\u5148\uff0c\u4f8b\u5982\u56fe\u7247\u3001CSS \u548c JavaScript\uff1b<\/li><li><code>$uri\/<\/code>\uff1a\u771f\u5b9e\u76ee\u5f55\u4f18\u5148\uff1b<\/li><li><code>\/index.php?$args<\/code>\uff1a\u5176\u4f59\u8bf7\u6c42\u5185\u90e8\u8f6c\u7ed9 WordPress\uff0c\u5e76\u4fdd\u7559\u539f\u67e5\u8be2\u53c2\u6570\u3002<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u672c\u7ad9\u539f\u6709\u51e0\u7ec4\u7cbe\u786e\u524d\u7f00\u4ee3\u7406\u89c4\u5219\uff0c\u4fee\u590d\u65f6\u5168\u90e8\u4fdd\u7559\u3002Nginx \u7684 <a href=\"https:\/\/nginx.org\/en\/docs\/http\/ngx_http_core_module.html#location\">@@IFORZINLINE0@@ \u5339\u914d\u89c4\u5219<\/a> \u51b3\u5b9a\u4e86 <code>^~<\/code> \u524d\u7f00\u548c\u7cbe\u786e\u5339\u914d\u4ecd\u53ef\u5904\u7406\u81ea\u5df1\u7684\u8def\u5f84\uff0c\u666e\u901a WordPress \u8bf7\u6c42\u624d\u8d70\u901a\u7528 fallback\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4fee\u6539\u540e\u5148\u68c0\u67e5\uff0c\u6210\u529f\u624d\u5e73\u6ed1\u91cd\u8f7d\u3002\u4e0b\u9762\u53ea\u9002\u7528\u4e8e PATH \u4e2d\u7684 <code>nginx<\/code> \u5c31\u662f\u8fd0\u884c\u4e2d\u5b9e\u4f8b\u7684\u5e38\u89c4\u5b89\u88c5\uff1b\u9762\u677f\u6216\u591a\u5b9e\u4f8b\u73af\u5883\u5fc5\u987b\u4f7f\u7528\u7ebf\u4e0a master \u5bf9\u5e94\u7684\u4e8c\u8fdb\u5236\u3001\u914d\u7f6e\u8def\u5f84\u548c reload \u65b9\u5f0f\uff0c\u5e76\u4fdd\u8bc1\u6d4b\u8bd5\u4e0e\u91cd\u8f7d\u9488\u5bf9\u540c\u4e00\u5b9e\u4f8b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-bash\">sudo nginx -t\nsudo nginx -s reload<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/nginx.org\/en\/docs\/switches.html\">@@IFORZINLINE0@@<\/a> \u80fd\u53d1\u73b0\u8bed\u6cd5\u9519\u8bef\u548c\u65e0\u6cd5\u6253\u5f00\u7684\u5f15\u7528\u6587\u4ef6\uff1b<a href=\"https:\/\/nginx.org\/en\/docs\/control.html#reconfiguration\">reload \u673a\u5236<\/a> \u4f1a\u5728\u65b0\u914d\u7f6e\u65e0\u6cd5\u5e94\u7528\u65f6\u7ee7\u7eed\u4f7f\u7528\u65e7\u914d\u7f6e\u3002\u4f46\u8bed\u6cd5\u6b63\u786e\u4e0d\u4ee3\u8868\u8def\u7531\u8bed\u4e49\u6b63\u786e\uff0c\u6240\u4ee5 HTTP \u56de\u5f52\u4e00\u6b65\u4e5f\u4e0d\u80fd\u5c11\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u4e2a\u5e38\u89c1\u8bef\u4fee<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u521b\u5efa\u4e00\u4efd\u5b9e\u4f53 robots.txt<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u672c\u6587\u8fd9\u79cd\u201c\u5b9e\u4f53\u6587\u4ef6\u4f18\u5148\u201d\u7684\u914d\u7f6e\u4e2d\uff0c\u8fd9\u53ea\u80fd\u906e\u4f4f\u4e00\u4e2a\u75c7\u72b6\u3002<code>wp-sitemap.xml<\/code>\u3001\u5b50 sitemap \u548c\u5176\u4ed6 WordPress \u865a\u62df\u8def\u7531\u4ecd\u7136\u5931\u6548\uff0c\u800c\u4e14\u5b9e\u4f53\u6587\u4ef6\u4f1a\u7ed5\u8fc7\u6838\u5fc3\u52a8\u6001\u7ef4\u62a4\u7684 <code>Sitemap:<\/code> \u884c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u53ea\u7ed9 wp-sitemap.xml \u5199\u4e00\u4e2a\u7279\u4f8b<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u7d22\u5f15\u4e5f\u8bb8\u6062\u590d\u4e86\uff0c\u4f46 <code>\/wp-sitemap-posts-post-1.xml<\/code> \u4e4b\u7c7b\u7684\u5b50\u8def\u7531\u4ecd\u4f1a 404\u3002\u6b63\u786e\u4fee\u590d\u70b9\u662f\u901a\u7528\u524d\u7aef\u63a7\u5236\u5668\u4ea4\u63a5\uff0c\u800c\u4e0d\u662f\u53ea\u7167\u987e\u4e00\u4e2a URL\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5220\u9664 PHP location \u91cc\u7684\u6587\u4ef6\u5b58\u5728\u6027\u68c0\u67e5<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f88\u591a\u7ad9\u70b9\u4f1a\u5728 PHP handler \u4e2d\u4fdd\u7559 <code>try_files $uri =404<\/code>\uff0c\u9632\u6b62\u628a\u4e0d\u5b58\u5728\u7684\u4efb\u610f <code>.php<\/code> \u811a\u672c\u4ea4\u7ed9 PHP-FPM\u3002\u4e0d\u8981\u4e3a\u4e86\u4fee\u524d\u53f0\u8def\u7531\u628a\u8fd9\u5c42\u5b89\u5168\u68c0\u67e5\u62c6\u6389\uff1b\u5e94\u7531 <code>location \/<\/code> \u5185\u90e8\u8df3\u5230\u771f\u5b9e\u5b58\u5728\u7684 <code>\/index.php<\/code>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u540c\u6837\uff0c\u53cd\u590d\u6267\u884c <a href=\"https:\/\/developer.wordpress.org\/reference\/classes\/wp_rewrite\/flush_rules\/\">@@IFORZINLINE0@@<\/a> \u4e5f\u4e0d\u89e3\u51b3\u8fd9\u4e2a\u6545\u969c\u3002\u5b83\u53ea\u5237\u65b0 WordPress \u7684\u91cd\u5199\u89c4\u5219\u7f13\u5b58\uff0c\u800c\u4e14\u6210\u672c\u8f83\u9ad8\uff1b\u8bf7\u6c42\u6ca1\u6709\u8fdb\u5165 <code>index.php<\/code> \u65f6\uff0c\u7f13\u5b58\u91cc\u7684\u89c4\u5219\u6839\u672c\u6ca1\u6709\u673a\u4f1a\u751f\u6548\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u53d1\u5e03\u524d\u5fc5\u987b\u5b8c\u6210\u7684\u6574\u7ad9\u9a8c\u6536<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u672c\u6b21\u4fee\u590d\u540e\uff0c\u4e0d\u53ea\u68c0\u67e5\u201c\u4e24\u4e2a URL \u53d8\u6210 200\u201d\uff0c\u800c\u662f\u6309\u4e0b\u9762\u7684\u4fe1\u53f7\u4e00\u8d77\u9a8c\u6536\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>\/robots.txt<\/code> \u8fd4\u56de 200\uff0cContent-Type \u4ee5 <code>text\/plain<\/code> \u5f00\u5934\uff0c\u5185\u5bb9\u5305\u542b\u6b63\u786e sitemap \u5730\u5740\uff1b<\/li><li><code>\/wp-sitemap.xml<\/code> \u8fd4\u56de 200\uff0cContent-Type \u4ee5 <code>application\/xml<\/code> \u5f00\u5934\uff0cXML \u53ef\u4ee5\u89e3\u6790\uff1b<\/li><li>sitemap \u4e2d\u81f3\u5c11\u4e00\u4e2a\u5b50 sitemap \u8fd4\u56de 200\uff1b<\/li><li>\u9996\u9875\u3001\u4ee3\u8868\u6587\u7ae0\u3001RSS \u548c\u9759\u6001\u8d44\u6e90\u7ee7\u7eed\u6b63\u5e38\uff1b<\/li><li>\u968f\u673a\u4e0d\u5b58\u5728\u8def\u5f84\u4ecd\u8fd4\u56de\u771f\u6b63\u7684 404\uff0c\u800c\u4e0d\u662f\u88ab\u9519\u8bef\u6539\u6210 200\uff1b<\/li><li>HTTP \u4ecd\u53ea\u8df3\u8f6c\u4e00\u6b21\u5230\u552f\u4e00 HTTPS \u4e3b\u57df\uff1b<\/li><li>\u8bbf\u95ee\u65e5\u5fd7\u6ca1\u6709\u65b0\u589e 5xx\uff0cNginx \u548c PHP \u9519\u8bef\u65e5\u5fd7\u6ca1\u6709\u65b0\u589e\u76f8\u5173\u9519\u8bef\u3002<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u672c\u7ad9\u5f53\u524d\u516c\u7f51\u590d\u6d4b\u7ed3\u679c\u662f\uff1arobots\u3001sitemap\u3001\u5b50 sitemap\u3001\u9996\u9875\u3001\u6587\u7ae0\u548c RSS \u5747\u4e3a\u4e25\u683c HTTPS 200\uff1b\u968f\u673a\u4e0d\u5b58\u5728\u8def\u5f84\u4e3a 404\uff1b\u4fee\u590d\u540e\u7684\u7edf\u8ba1\u7a97\u53e3\u6ca1\u6709 5xx\u3002\u51cc\u6668\u5907\u4efd\u7684\u6570\u636e\u5e93\u3001\u7ad9\u70b9\u6587\u4ef6\u548c\u670d\u52a1\u5668\u914d\u7f6e\u4e5f\u90fd\u901a\u8fc7\u6821\u9a8c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u56de\u6eda\u600e\u4e48\u505a<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c reload \u540e\u51fa\u73b0\u6587\u7ae0\u3001\u9759\u6001\u8d44\u6e90\u6216\u4ee3\u7406\u8def\u5f84\u56de\u5f52\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u7acb\u5373\u6062\u590d\u521a\u624d\u5907\u4efd\u7684\u76ee\u6807\u7ad9\u70b9\u914d\u7f6e\uff1b<\/li><li>\u518d\u6b21\u8fd0\u884c <code>nginx -t<\/code>\uff1b<\/li><li>\u68c0\u67e5\u901a\u8fc7\u540e\u5e73\u6ed1 reload\uff1b<\/li><li>\u91cd\u590d robots\u3001sitemap\u3001\u5b50 sitemap\u3001\u9996\u9875\u3001\u6587\u7ae0\u3001RSS\u3001\u968f\u673a 404 \u548c\u9519\u8bef\u65e5\u5fd7\u9a8c\u8bc1\u3002<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u8981\u7528\u201c\u91cd\u542f\u6574\u4e2a\u670d\u52a1\u5668\u201d\u4ee3\u66ff\u56de\u6eda\uff0c\u4e5f\u4e0d\u8981\u5728\u6545\u969c\u73b0\u573a\u540c\u65f6\u6539\u6c38\u4e45\u94fe\u63a5\u3001PHP \u914d\u7f6e\u548c\u63d2\u4ef6\u3002\u4e00\u6b21\u53ea\u6539\u4e00\u4e2a\u53d8\u91cf\uff0c\u624d\u80fd\u77e5\u9053\u662f\u54ea\u4e00\u9879\u771f\u6b63\u751f\u6548\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6700\u540e\u5224\u65ad<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>robots.txt<\/code> \u548c <code>wp-sitemap.xml<\/code> \u540c\u65f6 404\uff0c\u4e0d\u662f\u4e00\u4e2a\u53ef\u4ee5\u65e0\u6761\u4ef6\u5957\u7528\u7684\u201cNginx \u5fc5\u9519\u201d\u7ed3\u8bba\uff1b\u56fa\u5b9a\u94fe\u63a5\u72b6\u6001\u3001\u524d\u53f0 Home URL \u8def\u5f84\u3001\u7ad9\u70b9\u53ef\u7d22\u5f15\u72b6\u6001\u548c\u63d2\u4ef6\u90fd\u53ef\u80fd\u6539\u53d8\u7ed3\u679c\u3002\u4f46\u5f53 robots \u67e5\u8be2\u6b63\u6587\u6b63\u5e38\u3001\u6f02\u4eae\u8def\u5f84\u5931\u8d25\uff0csitemap \u67e5\u8be2\u7531 WordPress \u660e\u786e\u91cd\u5b9a\u5411\u56de\u540c\u4e00\u4e2a\u5931\u6548\u6f02\u4eae\u8def\u5f84\uff0c\u5e76\u4e14\u4e24\u8005\u53d7\u540c\u4e00\u4e2a Nginx location \u5904\u7406\u65f6\uff0c\u8bc1\u636e\u5df2\u7ecf\u8db3\u591f\u96c6\u4e2d\uff1a\u5148\u4fee Web \u670d\u52a1\u5668\u5230\u524d\u7aef\u63a7\u5236\u5668\u7684\u4ea4\u63a5\uff0c\u800c\u4e0d\u662f\u51ed\u7a7a\u8865\u6587\u4ef6\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u6b21\u771f\u6b63\u6062\u590d\u7684\u4e5f\u4e0d\u53ea\u662f\u4e24\u4e2a SEO URL\uff0c\u800c\u662f\u6574\u7ec4 WordPress \u865a\u62df\u8def\u7531\u3002\u66f4\u591a\u7ecf\u8fc7\u5b9e\u9645\u56de\u6eda\u548c\u9a8c\u6536\u7684\u8bb0\u5f55\u4f1a\u6301\u7eed\u6574\u7406\u5728<a href=\"https:\/\/www.iforz.cn\/index.php\/archives\/\">\u6587\u7ae0\u5f52\u6863<\/a>\u91cc\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>robots.txt \u548c wp-sitemap.xml \u540c\u65f6\u8fd4\u56de 404\uff0c\u4e0d\u4e00\u5b9a\u662f WordPress \u6587\u4ef6\u4e22\u4e86\u3002\u672c\u6b21\u6545\u969c\u7684\u5171\u540c\u70b9\u662f Nginx \u6ca1\u6709\u628a\u4e24\u4e2a\u865a\u62df URL \u4ea4\u7ed9 index.php\uff1b\u672c\u6587\u7528\u67e5\u8be2\u5f62\u5f0f\u3001\u54cd\u5e94\u94fe\u548c\u6b63\u6587\u7c7b\u578b\u5b9a\u4f4d\u5206\u5c42\uff0c\u518d\u5b8c\u6210 try_files \u4fee\u590d\u3001\u56de\u6eda\u548c\u6574\u7ad9\u9a8c\u6536\u3002<\/p>\n","protected":false},"author":1,"featured_media":39,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[12,13,15,16,11,14],"class_list":["post-38","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-incidents","tag-nginx","tag-robots-txt","tag-seo","tag-try_files","tag-wordpress","tag-wp-sitemap-xml"],"_links":{"self":[{"href":"https:\/\/www.iforz.cn\/index.php\/wp-json\/wp\/v2\/posts\/38","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.iforz.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iforz.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iforz.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iforz.cn\/index.php\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":1,"href":"https:\/\/www.iforz.cn\/index.php\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"predecessor-version":[{"id":40,"href":"https:\/\/www.iforz.cn\/index.php\/wp-json\/wp\/v2\/posts\/38\/revisions\/40"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.iforz.cn\/index.php\/wp-json\/wp\/v2\/media\/39"}],"wp:attachment":[{"href":"https:\/\/www.iforz.cn\/index.php\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iforz.cn\/index.php\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iforz.cn\/index.php\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}