{"id":2166,"date":"2024-03-06T19:53:00","date_gmt":"2024-03-06T11:53:00","guid":{"rendered":"https:\/\/qishiya.com\/?p=2166"},"modified":"2024-03-06T19:53:00","modified_gmt":"2024-03-06T11:53:00","slug":"wordpress-%e6%80%8e%e4%b9%88%e6%a0%b7%e9%87%8d%e5%86%99-url","status":"publish","type":"post","link":"https:\/\/qishiya.com\/?p=2166","title":{"rendered":"wordpress \u600e\u4e48\u6837\u91cd\u5199 URL"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_61 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #ff6200;color:#ff6200\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #ff6200;color:#ff6200\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/qishiya.com\/?p=2166\/#%E4%B8%BA%E4%BB%80%E4%B9%88%E8%A6%81%E9%87%8D%E5%86%99\" title=\"\u4e3a\u4ec0\u4e48\u8981\u91cd\u5199\">\u4e3a\u4ec0\u4e48\u8981\u91cd\u5199<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/qishiya.com\/?p=2166\/#URL%E5%B8%B8%E8%A7%81%E7%9A%84%E6%A0%BC%E5%BC%8F\" title=\"URL\u5e38\u89c1\u7684\u683c\u5f0f\">URL\u5e38\u89c1\u7684\u683c\u5f0f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/qishiya.com\/?p=2166\/#%E6%80%8E%E4%B9%88%E5%AE%9E%E7%8E%B0\" title=\"\u600e\u4e48\u5b9e\u73b0\">\u600e\u4e48\u5b9e\u73b0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/qishiya.com\/?p=2166\/#%E4%BF%AE%E6%94%B9Nginx\" title=\"\u4fee\u6539Nginx\">\u4fee\u6539Nginx<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/qishiya.com\/?p=2166\/#%E6%B7%BB%E5%8A%A0%E9%87%8D%E5%86%99%E8%A7%84%E5%88%99%E5%B9%B6%E5%88%B7%E6%96%B0\" title=\"\u6dfb\u52a0\u91cd\u5199\u89c4\u5219\u5e76\u5237\u65b0\">\u6dfb\u52a0\u91cd\u5199\u89c4\u5219\u5e76\u5237\u65b0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/qishiya.com\/?p=2166\/#%E6%B7%BB%E5%8A%A0permalink%E7%94%9F%E6%88%90%E5%87%BD%E6%95%B0\" title=\"\u6dfb\u52a0permalink\u751f\u6210\u51fd\u6570\">\u6dfb\u52a0permalink\u751f\u6210\u51fd\u6570<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/qishiya.com\/?p=2166\/#%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9\" title=\"\u6ce8\u610f\u4e8b\u9879\">\u6ce8\u610f\u4e8b\u9879<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%B8%BA%E4%BB%80%E4%B9%88%E8%A6%81%E9%87%8D%E5%86%99\"><\/span>\u4e3a\u4ec0\u4e48\u8981\u91cd\u5199<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>wordpress \u81ea\u8eab\u7684 permalink \u5bf9 SEO \u975e\u5e38\u4e0d\u53cb\u597d\uff0c\u6211\u6293\u53d6\u4e86\u4e0d\u540c\u5173\u952e\u8bcd\u5728 Gooogle \u7684\u641c\u7d22\u5217\u8868\uff0c\u53d1\u73b0\u4e00\u4e2a\u826f\u597d\u7684 URL \u662f\u8981\u57fa\u672c\u7684\u8303\u5f0f\u7684\uff0c\u4e0d\u80fd\u592a\u957f\uff0c\u4e5f\u4e0d\u80fd\u592a\u77ed\uff0c\u6709\u57fa\u672c\u7684\u8bed\u4e49\uff0cwordpress \u7684URL\u7684\u81ea\u5b9a\u4e49\u6837\u5f0f\u5c31\u53ea\u6709\u51e0\u79cd\uff0c\u5982\u679c\u60f3\u7528\u66f4\u591a\u7684\uff0c\u5c31\u8981\u4e70\u63d2\u4ef6\uff0c\u76f8\u5173\u63d2\u4ef6\u4e00\u5e74\u4e00\u4e2a\u7ad9\u70b9\u63a5\u8fd1 60 \u6b27\u5143\uff0c\u6240\u4ee5\u6211\u51b3\u5b9a\u81ea\u5df1\u5b9e\u73b0\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"URL%E5%B8%B8%E8%A7%81%E7%9A%84%E6%A0%BC%E5%BC%8F\"><\/span>URL\u5e38\u89c1\u7684\u683c\u5f0f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><img decoding=\"async\" src=\"https:\/\/tutu-1252436247.cos.ap-beijing.myqcloud.com\/2024\/03\/20240306TLMZbU.jpg\" alt=\"20240306TLMZbU\"\/><\/figure>\n\n\n\n<p>\u4e0a\u9762\u8fd9\u4e9b\u662f\u7cfb\u7edf\u81ea\u5e26\u7684\uff0c\u57fa\u672c\u4e0a\u6ca1\u6709\u4e00\u4e2a\u662f URL \u53cb\u597d\u7684\uff0c\u6211\u7528 WooCommerce \u5356\u53d1\u5e03\u4ea7\u54c1\uff0c\u5bf9\u4e8e\u4ea7\u54c1\u7684\u81ea\u5b9a\u4e49 URL\uff0c\u5c31\u66f4\u5c11\uff0c\u6211\u60f3\u5b9e\u73b0\u4ea7\u54c1\u8be6\u60c5\u9875\u9762\u7684 URL\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;www.qishiya.com\/product-detail\/How-To-Diy-Yoke-For-Model3_1600793866871.html<\/code><\/pre>\n\n\n\n<p>\u8fd9\u4e2a\u5546\u54c1\u8be6\u60c5\u9875\u9762\u7684 URL \u6709\u5982\u4e0b\u51e0\u4e2a\u4f18\u70b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7b80\u77ed<\/li>\n\n\n\n<li>\u7ed3\u6784\u6e05\u6670<\/li>\n\n\n\n<li>\u6709\u8bed\u4e49\u3002<\/li>\n<\/ul>\n\n\n\n<p>product-detail \u8fd9\u4e2a\u7ed3\u6784\uff0c\u660e\u786e\u4e86\u662f\u4e00\u4e2a\u5546\u54c1\u8be6\u60c5\u9875\u9762\u3002<\/p>\n\n\n\n<p>How-To-Diy-Yoke-For-Model3 \u660e\u786e\u4e86\u8bed\u4e49\u3002<\/p>\n\n\n\n<p>\u6574\u4f53URL\u7684\u5b57\u7b26\u5728\u67d0\u4e00\u4e2a\u8303\u56f4\u91cc\u9762\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%80%8E%E4%B9%88%E5%AE%9E%E7%8E%B0\"><\/span>\u600e\u4e48\u5b9e\u73b0<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u9996\u5148\u8981\u8bbe\u8ba1\u4e00\u4e0b\u4f60\u7684\u6240\u6709URL\uff0c\u56e0\u4e3a\u4e00\u65e6\u63d0\u4ea4\u5230\u641c\u7d22\u5f15\u64ce\uff0c\u4f60\u8981\u53d8\u66f4\u7684\u6210\u672c\u6709\u70b9\u5927\uff0c\u4ee5\u5b9e\u73b0\u5982\u4e0b\u7684 URL \u4e3a\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;www.qishiya.com\/product-detail\/How-To-Diy-Yoke-For-Model3_1600793866871.html<\/code><\/pre>\n\n\n\n<p>\u8bbe\u8ba1\u5b8c\u6210\u4e4b\u540e\uff0c\u5982\u679c\u4e0d\u7528\u63d2\u4ef6\uff0c\u90a3\u5c31\u662f\u6309\u5982\u4e0b\u8981\u6c42\u66f4\u6539\u4ee3\u7801\u5c31\u53ef\u4ee5\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%BF%AE%E6%94%B9Nginx\"><\/span>\u4fee\u6539Nginx<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>location \/ {\n        index index.php index.html index.htm;\n        try_files $uri $uri\/ \/index.php?$args;\n    }<\/code><\/pre>\n\n\n\n<p>\u8fd9\u6837\u5c31\u652f\u6301\u4e86rewrite \u7684\u6240\u6709\u914d\u7f6e\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%B7%BB%E5%8A%A0%E9%87%8D%E5%86%99%E8%A7%84%E5%88%99%E5%B9%B6%E5%88%B7%E6%96%B0\"><\/span>\u6dfb\u52a0\u91cd\u5199\u89c4\u5219\u5e76\u5237\u65b0<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>function custom_rewrite_rules($rules) {\n    $newrules = array();\n    $newrules&#91;'product-detail\/(.+?)_(\\d+)\\.html$'] = 'index.php?post_type=product&amp;p=$matches&#91;2]';\n    return $newrules + $rules;\n}\nadd_filter('rewrite_rules_array', 'custom_rewrite_rules');\n\n\n\/\/ \u5237\u65b0permalinks\u89c4\u5219\nadd_action( 'admin_init', 'flush_rewrite_rules_123' );\nfunction flush_rewrite_rules_123() {\n    flush_rewrite_rules();\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%B7%BB%E5%8A%A0permalink%E7%94%9F%E6%88%90%E5%87%BD%E6%95%B0\"><\/span>\u6dfb\u52a0permalink\u751f\u6210\u51fd\u6570<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>function custom_woocommerce_product_post_type_link( $permalink, $post ) {\n    \/\/ \u53ea\u9488\u5bf9\u5546\u54c1\u4fee\u6539\u6c38\u4e45\u94fe\u63a5\n    if ( $post->post_type !== 'product' || empty($permalink) ) {\n        return $permalink;\n    }\n\n\n    $timestamp = $post->ID;\n\t\n\t$product_name = get_the_title( $post );\n\t\n\t  \/\/ \u83b7\u53d6\u5546\u54c1\u540d\u79f0\n    $product_name = explode( ' ', $product_name );\n    $product_name = array_slice( $product_name, 0, 6 );\n    $product_name = implode( ' ', $product_name );\n\n\n\t\n    \/\/ \u6784\u5efa\u81ea\u5b9a\u4e49URL\n    $permalink = trailingslashit( home_url( '\/product-detail\/' . $product_name . '_' . $timestamp . '.html' ) );\n\n    \/\/ \u66ff\u6362 URL \u4e2d\u7684\u7a7a\u683c\n    $permalink = str_replace( ' ', '-', $permalink );\n\t$permalink = trim( $permalink, '\/' );\n    \/\/ \u6784\u5efa\u81ea\u5b9a\u4e49URL\n    \/\/$permalink = trailingslashit( home_url( '\/product-detail\/' . $product_name . '_' . $timestamp . '.html' ) );\n\n    return $permalink;\n}\nadd_filter( 'post_type_link', 'custom_woocommerce_product_post_type_link', 10, 2 );\n\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9\"><\/span>\u6ce8\u610f\u4e8b\u9879<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u4ee3\u7801\u6211\u7edf\u4e00\u653e\u5230\u4e86<strong>Code Snippets<\/strong> \u8fd9\u4e2a\u63d2\u4ef6\u4e0b\u7edf\u4e00\u7ba1\u7406\uff0c\u800c\u4e0d\u662f\u76f4\u63a5\u4fee\u6539\u4e3b\u9898\u3002<\/li>\n\n\n\n<li>\u6dfb\u52a0\u4e86\u89c4\u5219\u4e00\u5b9a\u8981\u5237\u65b0\u89c4\u5219\uff0c\u662f\u7528\u4ee3\u7801\u5237\u65b0\u3002<\/li>\n\n\n\n<li>\u5bf9\u4e8e\u91cd\u5199\u89c4\u5219\u7684\u6027\u80fd\u6211\u8fd8\u6ca1\u6709\u592a\u591a\u7684\u5173\u6ce8\uff0c\u56e0\u4e3a\u6211\u7684\u673a\u5668\u662f\u7269\u7406\u673a\uff0c\u6682\u65f6\u53d1\u73b0\u6ca1\u6709\u4ec0\u4e48\u5f71\u54cd\u3002<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3a\u4ec0\u4e48\u8981\u91cd\u5199 wordpress \u81ea\u8eab\u7684 permalink \u5bf9 SEO \u975e\u5e38\u4e0d\u53cb\u597d\uff0c\u6211\u6293\u53d6\u4e86\u4e0d\u540c\u5173\u952e\u8bcd\u5728 Gooogle \u7684\u641c\u7d22\u5217\u8868\uff0c\u53d1\u73b0\u4e00\u4e2a\u826f\u597d\u7684 URL \u662f\u8981\u57fa\u672c\u7684\u8303\u5f0f\u7684\uff0c\u4e0d\u80fd\u592a\u957f\uff0c\u4e5f\u4e0d\u80fd\u592a\u77ed\uff0c\u6709\u57fa\u672c\u7684\u8bed\u4e49\uff0cwordpress \u7684UR &#8230; <a title=\"wordpress \u600e\u4e48\u6837\u91cd\u5199 URL\" class=\"read-more\" href=\"https:\/\/qishiya.com\/?p=2166\" aria-label=\"\u66f4\u591a wordpress \u600e\u4e48\u6837\u91cd\u5199 URL\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":2169,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[599],"tags":[],"class_list":["post-2166","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-seo","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/posts\/2166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qishiya.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2166"}],"version-history":[{"count":1,"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/posts\/2166\/revisions"}],"predecessor-version":[{"id":2168,"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/posts\/2166\/revisions\/2168"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/media\/2169"}],"wp:attachment":[{"href":"https:\/\/qishiya.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qishiya.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qishiya.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}