{"id":22946,"date":"2024-11-21T09:01:27","date_gmt":"2024-11-21T01:01:27","guid":{"rendered":"https:\/\/fwq.ai\/blog\/22946\/"},"modified":"2024-11-21T09:01:27","modified_gmt":"2024-11-21T01:01:27","slug":"thinkphp%e7%bd%91%e5%9d%80%e9%9a%90%e8%97%8f%e6%a8%a1%e5%9d%97%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/22946\/","title":{"rendered":"thinkphp\u7f51\u5740\u9690\u85cf\u6a21\u5757\u5982\u4f55\u5b9e\u73b0"},"content":{"rendered":"<\/p>\n<p>\u6709\u65f6\u5728\u7f51\u7ad9\u5f00\u53d1\u4e2d\uff0c\u9700\u8981\u9690\u85cf\u9875\u9762\u7684\u5b9e\u9645\u7f51\u5740\uff0c\u4ee5\u9632\u6b62\u7528\u6237\u83b7\u53d6\u5230\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7f51\u5740\u9690\u85cf\u7684\u6a21\u5757\u3002<\/p>\n<p>\u8fd9\u4e2a\u6a21\u5757\u7684\u5b9e\u73b0\u65b9\u5f0f\u662f\u901a\u8fc7\u91cd\u5199URL\u7684\u5f62\u5f0f\u5b9e\u73b0\u7684\u3002\u5f53\u7528\u6237\u8bf7\u6c42\u4e00\u4e2aURL\u65f6\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u5c06URL\u8fdb\u884c\u91cd\u5199\uff0c\u5e76\u4e14\u8fd4\u56de\u5230\u524d\u7aef\u9875\u9762\u3002\u56e0\u6b64\uff0c\u7528\u6237\u65e0\u6cd5\u76f4\u63a5\u8bbf\u95ee\u5230\u771f\u5b9e\u7684URL\u5730\u5740\u3002<\/p>\n<p>\u4e3a\u4e86\u4f7f\u7528\u8fd9\u4e2a\u6a21\u5757\uff0c\u4f60\u9700\u8981\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u8fdb\u884c\u4e00\u4e9b\u4fee\u6539\u3002\u9996\u5148\uff0c\u4f60\u9700\u8981\u5f00\u542fURL\u91cd\u5199\u529f\u80fd\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cthinkphp\u6846\u67b6\u4e0d\u542f\u7528URL\u91cd\u5199\u529f\u80fd\uff0c\u9700\u8981\u624b\u52a8\u5f00\u542f\u3002\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u4f60\u9700\u8981\u6dfb\u52a0\u5982\u4e0b\u914d\u7f6e\uff1a<\/p>\n<pre>'URL_MODEL'&nbsp;=&amp;gt;&nbsp;2,&nbsp;\/\/\u5f00\u542fRewrite\u6a21\u5f0f\n'URL_ROUTER_ON'&nbsp;=&amp;gt;&nbsp;true,&nbsp;\/\/\u5f00\u542f\u8def\u7531\u529f\u80fd\n'URL_ROUTE_RULES'&nbsp;=&amp;gt;&nbsp;array(\n&nbsp;&nbsp;&nbsp;&nbsp;\/\/\u5b9a\u4e49\u8def\u7531\u89c4\u5219\n),<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u4f60\u9700\u8981\u5b9a\u4e49\u4e00\u4e9b\u8def\u7531\u89c4\u5219\u3002\u8def\u7531\u89c4\u5219\u662f\u6307\u5c06URL\u8fdb\u884c\u91cd\u5199\u7684\u89c4\u5219\u3002\u4f8b\u5982\uff0c\u7528\u6237\u8bbf\u95eehttp:\/\/www.example.com\/article\/1\uff0c\u5b9e\u9645\u4e0a\u8c03\u7528\u7684\u662fhttp:\/\/www.example.com\/index.php?s=\/home\/article&amp;id=1\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u5b9a\u4e49\u8def\u7531\u89c4\u5219\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>'URL_ROUTE_RULES'&nbsp;=&amp;gt;&nbsp;array(\n&nbsp;&nbsp;&nbsp;&nbsp;'article\/:id'&nbsp;=&amp;gt;&nbsp;'home\/article',\n),<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u4e2a\u89c4\u5219\u7684\u610f\u601d\u662f\uff0c\u5c06http:\/\/www.example.com\/article\/1\u8fd9\u4e2aURL\u91cd\u5199\u4e3ahttp:\/\/www.example.com\/index.php?s=\/home\/article&amp;id=1\u3002\u5176\u4e2d\uff0c:id\u8868\u793a\u4e00\u4e2a\u53d8\u91cf\uff0c\u53ef\u4ee5\u5339\u914d\u4efb\u610f\u4e00\u4e2a\u6570\u5b57\u3002<\/p>\n<p>\u6709\u4e86\u8fd9\u4e9b\u914d\u7f6e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528\u7f51\u5740\u9690\u85cf\u6a21\u5757\u4e86\u3002\u5982\u679c\u60f3\u8981\u9690\u85cf\u6587\u7ae0\u5217\u8868\u9875\u9762\u7684URL\uff0c\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u8def\u7531\u89c4\u5219\u6765\u5b9e\u73b0\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>'URL_ROUTE_RULES'&nbsp;=&amp;gt;&nbsp;array(\n&nbsp;&nbsp;&nbsp;&nbsp;'articles'&nbsp;=&amp;gt;&nbsp;'home\/article\/lists',\n),<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u4e2a\u89c4\u5219\u7684\u610f\u601d\u662f\uff0c\u5c06http:\/\/www.example.com\/articles\u8fd9\u4e2aURL\u91cd\u5199\u4e3ahttp:\/\/www.example.com\/index.php?s=\/home\/article\/lists\u3002\u7528\u6237\u8bbf\u95eehttp:\/\/www.example.com\/articles\u65f6\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u5c06URL\u91cd\u5199\u4e3ahttp:\/\/www.example.com\/index.php?s=\/home\/article\/lists\uff0c\u5e76\u8fd4\u56de\u5230\u524d\u7aef\u9875\u9762\u3002<\/p>\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u4f7f\u7528thinkphp\u7684\u7f51\u5740\u9690\u85cf\u6a21\u5757\u975e\u5e38\u7b80\u5355\u3002\u901a\u8fc7\u7b80\u5355\u7684\u914d\u7f6e\uff0c\u6211\u4eec\u53ef\u4ee5\u9690\u85cf\u7f51\u5740\uff0c\u4ece\u800c\u4fdd\u969c\u7f51\u7ad9\u7684\u5b89\u5168\u6027\u548c\u7528\u6237\u7684\u9690\u79c1\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u7f51\u5740\u9690\u85cf\u6a21\u5757\u5982\u4f55\u5b9e\u73b0\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u65f6\u5728\u7f51\u7ad9\u5f00\u53d1\u4e2d\uff0c\u9700\u8981\u9690\u85cf\u9875\u9762\u7684\u5b9e\u9645\u7f51\u5740\uff0c\u4ee5\u9632\u6b62\u7528\u6237\u83b7\u53d6\u5230\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7f51\u5740\u9690\u85cf\u7684\u6a21\u5757\u3002 \u8fd9\u4e2a\u6a21\u5757\u7684\u5b9e\u73b0\u65b9\u5f0f\u662f\u901a\u8fc7\u91cd\u5199URL\u7684\u5f62\u5f0f\u5b9e\u73b0\u7684\u3002\u5f53\u7528\u6237\u8bf7\u6c42\u4e00\u4e2aURL\u65f6\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u5c06URL\u8fdb\u884c\u91cd\u5199\uff0c\u5e76\u4e14\u8fd4\u56de\u5230\u524d\u7aef\u9875\u9762\u3002\u56e0\u6b64\uff0c\u7528\u6237\u65e0\u6cd5\u76f4\u63a5\u8bbf\u95ee\u5230\u771f\u5b9e\u7684URL\u5730\u5740\u3002 \u4e3a\u4e86\u4f7f\u7528\u8fd9\u4e2a\u6a21\u5757\uff0c\u4f60\u9700\u8981\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u8fdb\u884c\u4e00\u4e9b\u4fee\u6539\u3002\u9996\u5148\uff0c\u4f60\u9700\u8981\u5f00\u542fURL\u91cd\u5199\u529f\u80fd\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cthinkphp\u6846\u67b6\u4e0d\u542f\u7528URL\u91cd\u5199\u529f\u80fd\uff0c\u9700\u8981\u624b\u52a8\u5f00\u542f\u3002\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u4f60\u9700\u8981\u6dfb\u52a0\u5982\u4e0b\u914d\u7f6e\uff1a &#8216;URL_MODEL&#8217;&nbsp;=&amp;gt;&nbsp;2,&nbsp;\/\/\u5f00\u542fRewrite\u6a21\u5f0f &#8216;URL_ROUTER_ON&#8217;&nbsp;=&amp;gt;&nbsp;true,&nbsp;\/\/\u5f00\u542f\u8def\u7531\u529f\u80fd &#8216;URL_ROUTE_RULES&#8217;&nbsp;=&amp;gt;&nbsp;array( &nbsp;&nbsp;&nbsp;&nbsp;\/\/\u5b9a\u4e49\u8def\u7531\u89c4\u5219 ), \u767b\u5f55\u540e\u590d\u5236 \u63a5\u4e0b\u6765\uff0c\u4f60\u9700\u8981\u5b9a\u4e49\u4e00\u4e9b\u8def\u7531\u89c4\u5219\u3002\u8def\u7531\u89c4\u5219\u662f\u6307\u5c06URL\u8fdb\u884c\u91cd\u5199\u7684\u89c4\u5219\u3002\u4f8b\u5982\uff0c\u7528\u6237\u8bbf\u95eehttp:\/\/www.example.com\/article\/1\uff0c\u5b9e\u9645\u4e0a\u8c03\u7528\u7684\u662fhttp:\/\/www.example.com\/index.php?s=\/home\/article&amp;id=1\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u5b9a\u4e49\u8def\u7531\u89c4\u5219\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a &#8216;URL_ROUTE_RULES&#8217;&nbsp;=&amp;gt;&nbsp;array( &nbsp;&nbsp;&nbsp;&nbsp;&#8216;article\/:id&#8217;&nbsp;=&amp;gt;&nbsp;&#8216;home\/article&#8217;, ), \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u4e2a\u89c4\u5219\u7684\u610f\u601d\u662f\uff0c\u5c06http:\/\/www.example.com\/article\/1\u8fd9\u4e2aURL\u91cd\u5199\u4e3ahttp:\/\/www.example.com\/index.php?s=\/home\/article&amp;id=1\u3002\u5176\u4e2d\uff0c:id\u8868\u793a\u4e00\u4e2a\u53d8\u91cf\uff0c\u53ef\u4ee5\u5339\u914d\u4efb\u610f\u4e00\u4e2a\u6570\u5b57\u3002 \u6709\u4e86\u8fd9\u4e9b\u914d\u7f6e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528\u7f51\u5740\u9690\u85cf\u6a21\u5757\u4e86\u3002\u5982\u679c\u60f3\u8981\u9690\u85cf\u6587\u7ae0\u5217\u8868\u9875\u9762\u7684URL\uff0c\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u8def\u7531\u89c4\u5219\u6765\u5b9e\u73b0\uff0c\u5982\u4e0b\u6240\u793a\uff1a &#8216;URL_ROUTE_RULES&#8217;&nbsp;=&amp;gt;&nbsp;array( &nbsp;&nbsp;&nbsp;&nbsp;&#8216;articles&#8217;&nbsp;=&amp;gt;&nbsp;&#8216;home\/article\/lists&#8217;, ), \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u4e2a\u89c4\u5219\u7684\u610f\u601d\u662f\uff0c\u5c06http:\/\/www.example.com\/articles\u8fd9\u4e2aURL\u91cd\u5199\u4e3ahttp:\/\/www.example.com\/index.php?s=\/home\/article\/lists\u3002\u7528\u6237\u8bbf\u95eehttp:\/\/www.example.com\/articles\u65f6\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u5c06URL\u91cd\u5199\u4e3ahttp:\/\/www.example.com\/index.php?s=\/home\/article\/lists\uff0c\u5e76\u8fd4\u56de\u5230\u524d\u7aef\u9875\u9762\u3002 \u53ef\u4ee5\u770b\u5230\uff0c\u4f7f\u7528thinkphp\u7684\u7f51\u5740\u9690\u85cf\u6a21\u5757\u975e\u5e38\u7b80\u5355\u3002\u901a\u8fc7\u7b80\u5355\u7684\u914d\u7f6e\uff0c\u6211\u4eec\u53ef\u4ee5\u9690\u85cf\u7f51\u5740\uff0c\u4ece\u800c\u4fdd\u969c\u7f51\u7ad9\u7684\u5b89\u5168\u6027\u548c\u7528\u6237\u7684\u9690\u79c1\u3002 \u4ee5\u4e0a\u5c31\u662f\u7f51\u5740\u9690\u85cf\u6a21\u5757\u5982\u4f55\u5b9e\u73b0\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-22946","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22946","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=22946"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22946\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=22946"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=22946"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=22946"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}