{"id":315,"date":"2023-04-24T17:42:56","date_gmt":"2023-04-24T09:42:56","guid":{"rendered":"https:\/\/www.kenpai.com\/cms\/315\/"},"modified":"2023-04-24T17:42:56","modified_gmt":"2023-04-24T09:42:56","slug":"wordpress-%e4%bc%aa%e9%9d%99%e6%80%81%e8%a7%84%e5%88%99%e8%ae%be%e7%bd%ae%ef%bc%9aapache%e5%92%8cnginx%ef%bc%8c%e4%bb%a5%e5%8f%8a%e4%ba%8c%e7%ba%a7%e7%9b%ae%e5%bd%95%e8%a7%84%e5%88%99","status":"publish","type":"post","link":"https:\/\/www.kenpai.com\/cms\/315\/","title":{"rendered":"WordPress \u4f2a\u9759\u6001\u89c4\u5219\u8bbe\u7f6e\uff1aApache\u548cNginx\uff0c\u4ee5\u53ca\u4e8c\u7ea7\u76ee\u5f55\u89c4\u5219"},"content":{"rendered":"<\/p>\n<p>WordPress\u7684\u4f2a\u9759\u6001\u89c4\u5219\u662f\u6839\u636e\u670d\u52a1\u5668\u73af\u5883\u6765\u8bbe\u7f6e\u7684\uff0c\u4e0d\u540c\u7684PHP\u73af\u5883\u6709\u4e0d\u540c\u7684\u4f2a\u9759\u6001\u8bbe\u7f6e\u65b9\u6cd5\uff0c\u5e38\u89c1\u7684PHP\u73af\u5883\u6709\u00a0Apache\u548cNginx \uff0c\u4ee5\u4e0b\u6d69\u5b50\u5206\u522b\u5c31\u8fd9\u4e24\u79cd\u73af\u5883\u505a\u4f2a\u9759\u6001\u8bbe\u7f6e\u3002<\/p>\n<p>\u503c\u5f97\u4e00\u63d0\u7684\u662f\uff0c\u73b0\u5728\u6709\u5f88\u591a\u670d\u52a1\u5668\u9762\u677f\u5982\uff1a\u5b9d\u5854\uff0c\u53ef\u4ee5\u76f4\u63a5\u52fe\u9009\u5c31\u80fd\u8bbe\u7f6e\u4f2a\u9759\u6001\uff0c\u5982\u679c\u4f60\u6b63\u5728\u7528\uff0c\u5c31\u53ef\u4ee5\u4e0d\u7528\u7ee7\u7eed\u770b\u4e86\u3002<\/p>\n<hr \/>\n<p>Apache\u89c4\u5219\uff1a<\/p>\n<p>\u9996\u5148\u8981\u5f00\u542fapache\u7684url_rewrite\u6a21\u5757\uff08\u4e00\u822c\u9ed8\u8ba4\u90fd\u662f\u5f00\u542f\u7684\uff09\uff0c\u4e5f\u5c31\u662f\u5728httpd.conf\u4e2d\u53bb\u6389\u8fd9\u53e5\u8bdd\u7684\u6ce8\u91caLoadModule rewrite_module modules\/mod_rewrite.so\uff0chttpd.conf\u4e2d\u627e\u5230AllowOverride\uff0c\u628aAllowOverride None\u4fee\u6539\u6210AllowOverride all<\/p>\n<p>\u7f51\u7ad9\u6839\u76ee\u5f55\u4e0b\u8981\u6709 <code>.htaccess<\/code> \u6587\u4ef6\uff0c\u7136\u540e\u5c06\u4e0b\u9762\u7684\u4ee3\u7801\u590d\u5236\u8fdb\u53bb\u3002<\/p>\n<pre><code>&lt;ifmodule mod_rewrite.c&gt;\n    RewriteEngine On\n    RewriteBase \/\n    RewriteRule ^index\\.php$ - [L]\n    RewriteCond %{REQUEST_FILENAME} !-f\n    RewriteCond %{REQUEST_FILENAME} !-d\n    RewriteRule . \/index.php [L]\n&lt;\/ifmodule&gt;<\/code><\/pre>\n<p>WordPress\u5728Apache\u73af\u5883\u4e0b\u4e8c\u7ea7\u76ee\u5f55\u5efa\u7ad9\u4f2a\u9759\u6001\u64cd\u4f5c\u65b9\u5f0f\u540c\u4e0a\u3002<\/p>\n<hr \/>\n<p>Nginx\u89c4\u5219\uff1a<\/p>\n<p>\u64cd\u4f5c\u65b9\u6cd5\uff1a\u4ee5\u4e0b\u4ee3\u7801\u52a0\u5165\u5230\u7f51\u7ad9\u7684\u914d\u7f6e\u6587\u4ef6 xxxx.conf \u4e2d\u7684 server{} \u4e2d\u3002<\/p>\n<p><strong> \u6839\u76ee\u5f55\u4e0bWordPress\u7684\u4f2a\u9759\u6001\u89c4\u5219\uff1a <\/strong><\/p>\n<pre><code>location \/ {\n    if (-f $request_filename\/index.html){\n        rewrite (.*) $1\/index.html break;\n    }\n    if (-f $request_filename\/index.php){\n        rewrite (.*) $1\/index.php;\n    }\n    if (!-f $request_filename){\n        rewrite (.*) \/index.php;\n    }\n}<\/code><\/pre>\n<p><strong> \u4e8c\u7ea7\u76ee\u5f55\u4e0bWordPress\u7684\u4f2a\u9759\u6001\u89c4\u5219\uff1a <\/strong><\/p>\n<p>\u6ce8\u610f\u5c06\u4ee5\u4e0b\u4ee3\u7801\u4e2d\u7684\u201c\u4e8c\u7ea7\u76ee\u5f55\u540d\u201d\u6362\u6210\u81ea\u5df1\u7684\u771f\u5b9e\u4e8c\u7ea7\u76ee\u5f55\u540d\u3002<\/p>\n<pre><code>location \/\u4e8c\u7ea7\u76ee\u5f55\u540d\/ {\n    if (-f $request_filename\/index.html){\n        rewrite (.*) $1\/index.html break;\n    }\n    if (-f $request_filename\/index.php){\n        rewrite (.*) $1\/index.php;\n    }\n    if (!-f $request_filename){\n        rewrite (.*) \/\u4e8c\u7ea7\u76ee\u5f55\u540d\/index.php;\n    }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p><strong>\u6458\u8981\uff1a<\/strong>\u4e00\u7bc7\u8fc7\u6389 WordPress \u4f2a\u9759\u6001<\/p>\n","protected":false},"author":1,"featured_media":4348,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3019],"tags":[3097,2997,3098,3099,3100,3101],"class_list":["post-315","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","tag-url-rewrite","tag-wordpress","tag-wordpress-","tag-3099","tag-3100","tag-3101"],"_links":{"self":[{"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/posts\/315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/comments?post=315"}],"version-history":[{"count":0,"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/posts\/315\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/media\/4348"}],"wp:attachment":[{"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/media?parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/categories?post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/tags?post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}