{"id":63569,"date":"2025-04-29T17:36:10","date_gmt":"2025-04-29T09:36:10","guid":{"rendered":"https:\/\/fwq.ai\/blog\/63569\/"},"modified":"2025-04-29T17:36:10","modified_gmt":"2025-04-29T09:36:10","slug":"nginx%e4%bc%aa%e9%9d%99%e6%80%81%e6%80%8e%e4%b9%88%e8%ae%be%e7%bd%ae-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/63569\/","title":{"rendered":"nginx\u4f2a\u9759\u6001\u600e\u4e48\u8bbe\u7f6e"},"content":{"rendered":"<blockquote><p>\n  \u95ee\u9898\uff1a\u4ec0\u4e48\u662f nginx \u4f2a\u9759\u6001\u8bbe\u7f6e\uff1f\u7b54\u6848\uff1a\u4f2a\u9759\u6001\u662f\u901a\u8fc7\u91cd\u5199 url\uff0c\u5c06\u52a8\u6001 url \u8f6c\u6362\u4e3a\u9759\u6001 url\uff0c\u4ece\u800c\u6539\u5584\u7f51\u7ad9\u7684 seo \u548c\u6027\u80fd\u3002\u6b65\u9aa4\uff1a\u6dfb\u52a0 rewrite \u6a21\u5757\uff1b\u521b\u5efa\u4f2a\u9759\u6001\u89c4\u5219\uff1b\u6fc0\u6d3b rewrite \u6a21\u5757\uff1b\u91cd\u542f nginx\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/27\/2024052721062293650.jpg\" class=\"aligncenter\" title=\"nginx\u4f2a\u9759\u6001\u600e\u4e48\u8bbe\u7f6e\u63d2\u56fe\" alt=\"nginx\u4f2a\u9759\u6001\u600e\u4e48\u8bbe\u7f6e\u63d2\u56fe\" \/><\/p>\n<p><strong> \u4f2a\u9759\u6001\u8bbe\u7f6e<\/strong><\/p>\n<p><strong>\u4ec0\u4e48\u662f\u4f2a\u9759\u6001\uff1f<\/strong><\/p>\n<p>\u4f2a\u9759\u6001\u662f\u901a\u8fc7\u5728\u670d\u52a1\u5668\u7aef\u5bf9 URL \u8fdb\u884c\u91cd\u5199\uff0c\u5c06\u52a8\u6001 URL \u8f6c\u6362\u4e3a\u9759\u6001 URL\uff0c\u4ece\u800c\u8ba9\u52a8\u6001\u7f51\u7ad9\u770b\u8d77\u6765\u50cf\u9759\u6001\u7f51\u7ad9\u3002\u8fd9\u53ef\u4ee5\u6539\u5584\u7f51\u7ad9\u7684 SEO \u548c\u6027\u80fd\u3002<\/p>\n<p><strong>Nginx \u4f2a\u9759\u6001\u8bbe\u7f6e\u6b65\u9aa4\uff1a<\/strong><\/p>\n<p><strong>1. \u5728 nginx \u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0 rewrite \u6a21\u5757<\/strong><\/p>\n<pre>load_module rewrite_module modules\/ngx_rewrite.so;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u521b\u5efa\u4f2a\u9759\u6001\u89c4\u5219<\/strong><\/p>\n<p>\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0 rewrite \u6307\u4ee4\uff0c\u89c4\u5219\u5982\u4e0b\uff1a<\/p>\n<pre># \u5c06\u5e26\u6709 .html \u540e\u7f00\u7684 URL \u91cd\u5199\u4e3a index.php\nrewrite ^(.+).html$ \/index.php$1 last;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u89c4\u5219\u5c06\u5c06\u6240\u6709\u5e26\u6709 &#8220;.html&#8221; \u540e\u7f00\u7684 URL \u91cd\u5199\u4e3a\u4ee5 &#8220;index.php&#8221; \u5f00\u5934\u3001\u540e\u7f00\u4e3a\u539f\u6765\u7684 URL \u540e\u7f00\u7684\u65b0 URL\u3002<\/p>\n<p><strong>3. \u6fc0\u6d3b\u91cd\u5199\u6a21\u5757<\/strong><\/p>\n<p>\u5728 server \u5757\u4e2d\uff0c\u6fc0\u6d3b rewrite \u6a21\u5757\uff1a<\/p>\n<pre>server {\n    ...\n    rewrite_module on;\n    ...\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. \u91cd\u542f nginx<\/strong><\/p>\n<p>\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u9700\u8981\u91cd\u542f nginx \u670d\u52a1\u5668\u4ee5\u5e94\u7528\u66f4\u6539\u3002<\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u4ee5\u4e0b\u793a\u4f8b\u5c06\u6240\u6709\u5e26\u6709 &#8220;.html&#8221; \u540e\u7f00\u7684 URL \u91cd\u5199\u5230 &#8220;index.php&#8221;\uff1a<\/p>\n<pre>rewrite ^(.+).html$ \/index.php$1 last;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>\u4f2a\u9759\u6001\u89c4\u5219\u4e2d\uff0c$1 \u4ee3\u8868\u7b2c\u4e00\u4e2a\u6355\u83b7\u7ec4\u3002<\/li>\n<li>last \u6807\u5fd7\u786e\u4fdd\u89c4\u5219\u53ea\u5e94\u7528\u4e00\u6b21\u3002<\/li>\n<li>\u60a8\u9700\u8981\u6839\u636e\u81ea\u5df1\u7684\u7f51\u7ad9\u9700\u8981\u4fee\u6539\u89c4\u5219\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4f2a\u9759\u6001\u600e\u4e48\u8bbe\u7f6e\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898\uff1a\u4ec0\u4e48\u662f nginx \u4f2a\u9759\u6001\u8bbe\u7f6e\uff1f\u7b54\u6848\uff1a\u4f2a\u9759\u6001\u662f\u901a\u8fc7\u91cd\u5199 url\uff0c\u5c06\u52a8\u6001 url \u8f6c\u6362\u4e3a\u9759\u6001 url\uff0c\u4ece\u800c\u6539\u5584\u7f51\u7ad9\u7684 seo \u548c\u6027\u80fd\u3002\u6b65\u9aa4\uff1a\u6dfb\u52a0 rewrite \u6a21\u5757\uff1b\u521b\u5efa\u4f2a\u9759\u6001\u89c4\u5219\uff1b\u6fc0\u6d3b rewrite \u6a21\u5757\uff1b\u91cd\u542f nginx\u3002 \u4f2a\u9759\u6001\u8bbe\u7f6e \u4ec0\u4e48\u662f\u4f2a\u9759\u6001\uff1f \u4f2a\u9759\u6001\u662f\u901a\u8fc7\u5728\u670d\u52a1\u5668\u7aef\u5bf9 URL \u8fdb\u884c\u91cd\u5199\uff0c\u5c06\u52a8\u6001 URL \u8f6c\u6362\u4e3a\u9759\u6001 URL\uff0c\u4ece\u800c\u8ba9\u52a8\u6001\u7f51\u7ad9\u770b\u8d77\u6765\u50cf\u9759\u6001\u7f51\u7ad9\u3002\u8fd9\u53ef\u4ee5\u6539\u5584\u7f51\u7ad9\u7684 SEO \u548c\u6027\u80fd\u3002 Nginx \u4f2a\u9759\u6001\u8bbe\u7f6e\u6b65\u9aa4\uff1a 1. \u5728 nginx \u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0 rewrite \u6a21\u5757 load_module rewrite_module modules\/ngx_rewrite.so; \u767b\u5f55\u540e\u590d\u5236 2. \u521b\u5efa\u4f2a\u9759\u6001\u89c4\u5219 \u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0 rewrite \u6307\u4ee4\uff0c\u89c4\u5219\u5982\u4e0b\uff1a # \u5c06\u5e26\u6709 .html \u540e\u7f00\u7684 URL \u91cd\u5199\u4e3a index.php rewrite ^(.+).html$ \/index.php$1 last; \u767b\u5f55\u540e\u590d\u5236 \u6b64\u89c4\u5219\u5c06\u5c06\u6240\u6709\u5e26\u6709 &#8220;.html&#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-63569","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63569","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=63569"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63569\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=63569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=63569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=63569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}