{"id":554,"date":"2021-09-03T10:43:16","date_gmt":"2021-09-03T02:43:16","guid":{"rendered":"http:\/\/www.danios.com\/?p=554"},"modified":"2021-12-20T10:42:54","modified_gmt":"2021-12-20T02:42:54","slug":"permalinks-error","status":"publish","type":"post","link":"https:\/\/www.oceansource.cc\/?p=554","title":{"rendered":"WordPress\u66f4\u6539\u56fa\u5b9a\u8fde\u63a5\uff08permalinks\uff09\u540e\u53ea\u80fd\u8bbf\u95ee\u9996\u9875\u95ee\u9898\u5904\u7406"},"content":{"rendered":"\n<p>\u4eca\u5929\u6574\u7406\u4e86\u4e00\u4e0b\u7f51\u7ad9\uff0c\u60f3\u5c06\u56fa\u5b9a\u94fe\u63a5\u8c03\u6574\u4e00\u4e0b\uff0c\u4f46\u662f\u53c8\u51fa\u73b0\u4e86\u53ea\u80fd\u8bbf\u95ee\u9996\u9875\uff0c\u5176\u4ed6\u5b50\u9875\u9762\u63d0\u793a\u65e0\u6cd5\u8bbf\u95ee\u7684\u95ee\u9898\uff0c\u8054\u60f3\u5230\u4e4b\u524d\u4e5f\u51fa\u73b0\u8fc7\u540c\u6837\u7684\u95ee\u9898\uff0c\u7136\u540e\u8fd9\u6b21\u5c31\u7814\u7a76\u4e86\u4e00\u4e0b\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"531\" src=\"http:\/\/www.danios.com\/wp-content\/uploads\/2021\/09\/image-1024x531.png\" alt=\"\" class=\"wp-image-555\" srcset=\"https:\/\/www.oceansource.cc\/wp-content\/uploads\/2021\/09\/image-1024x531.png 1024w, https:\/\/www.oceansource.cc\/wp-content\/uploads\/2021\/09\/image-300x156.png 300w, https:\/\/www.oceansource.cc\/wp-content\/uploads\/2021\/09\/image-768x398.png 768w, https:\/\/www.oceansource.cc\/wp-content\/uploads\/2021\/09\/image.png 1330w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u770b\u5230\u4e86<a href=\"https:\/\/wordpress.org\/support\/article\/using-permalinks\/\" target=\"_blank\" rel=\"noreferrer noopener\">wordpress\u5b98\u7f51\u5173\u4e8e\u56fa\u5b9a\u94fe\u63a5\u7684\u4ecb\u7ecd<\/a>\uff0c\u53d1\u73b0\u9700\u8981\u5f00\u542fapache\u7684mod_rewrite module\u624d\u80fd\u6b63\u5e38\u4f7f\u7528Pretty permalinks\uff0c<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u539f\u6587\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"mod_rewrite-pretty-permalinks\">mod_rewrite: \u201cPretty Permalinks\u201d&nbsp;<a href=\"https:\/\/wordpress.org\/support\/article\/using-permalinks\/#mod_rewrite-pretty-permalinks\">#mod_rewrite: \u201cPretty Permalinks\u201d<\/a><\/h3>\n\n\n\n<p>Using mod_rewrite or lighttpd you can produce much nicer permalinks (see&nbsp;<a href=\"https:\/\/wordpress.org\/support\/article\/introduction-to-blogging\/#pretty-permalinks\">Pretty Permalinks<\/a>). There are many different formats, but the most common, and most versatile looks like<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">http:\/\/example.com\/2012\/post-name\/<\/pre>\n\n\n\n<p>or<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">http:\/\/example.com\/2012\/12\/30\/post-name<\/pre>\n\n\n\n<p>Pretty permalinks are available under:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Apache web server with the mod_rewrite module<\/strong><\/li><li>Nginx using try-files,\u00a0e.g. according to this\u00a0<a href=\"http:\/\/nginxlibrary.com\/wordpress-permalinks\/\">tutorial<\/a><\/li><li><a href=\"https:\/\/www.hiawatha-webserver.org\/\">Hiawatha web server<\/a>\u00a0with UrlToolkit support enabled.<\/li><li>Lighttpd using\u00a0<a href=\"http:\/\/chrisjohnston.org\/2009\/setting-up-a-wordpress-blog-on-lighttpd\">a 404 handler<\/a>\u00a0or mod_rewrite<\/li><li>Caddy using rewrite, e.g. according to this\u00a0<a href=\"https:\/\/denbeke.be\/blog\/servers\/caddy-server-and-wordpress-php-fpm\/\">tutorial<\/a><\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p>\u968f\u540e\u627e\u4e86\u4e00\u4e0b\u5f00\u542f\u7684\u65b9\u6cd5\uff0c\u5728<a href=\"https:\/\/devops.ionos.com\/tutorials\/install-and-configure-mod_rewrite-for-apache-on-centos-7.html#enable-mod_rewrite-module\" target=\"_blank\" rel=\"noreferrer noopener\">\u8fd9\u91cc<\/a>\u627e\u5230\u4e86<\/p>\n\n\n\n<p>\u5982\u679c\u4e0d\u60f3\u6253\u5f00\u94fe\u63a5\u7684\u8bdd\uff0c\u76f4\u63a5\u5f80\u4e0b\u770b\u5373\u53ef\u3002<\/p>\n\n\n\n<p>\u6211\u76f4\u63a5\u628a\u5bf9\u5e94\u7684\u90e8\u5206\u62f7\u8d1d\u4e86\u51fa\u6765\uff0c\u5982\u679c\u60f3\u770b\u4e2d\u6587\u7684\u8bdd\u53ef\u4ee5\u62c9\u5230\u6700\u540e<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"enable-mod_rewrite-module\">Enable Mod_rewrite Module<\/h2>\n\n\n\n<p>The&nbsp;<code>mod_rewrite<\/code>&nbsp;module is enabled by default on CentOS 7. If you find it is not enabled on your server, you can enable it by editing&nbsp;<code>00-base.conf<\/code>&nbsp;file located in&nbsp;<code>\/etc\/httpd\/conf.modules.d\/<\/code>&nbsp;directory.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo nano \/etc\/httpd\/conf.modules.d\/00-base.conf\n\n<\/pre><\/div>\n\n\n<p>Add or uncomment the following line:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nLoadModule rewrite_module modules\/mod_rewrite.so\n\n<\/pre><\/div>\n\n\n<p>Save and close the file, then restart the&nbsp;<code>httpd<\/code>&nbsp;service:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo systemctl restart httpd\n\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"enable-htaccess-file\">Enable .Htaccess File<\/h2>\n\n\n\n<p>Once the&nbsp;<code>mod_rewrite<\/code>&nbsp;module has been activated, you can set up your URL rewrites by creating an&nbsp;<code>.htaccess<\/code>&nbsp;file in your default document root directory. A&nbsp;<code>.htaccess<\/code>&nbsp;file allows us to modify our rewrite rules without accessing server configuration files. For this reason,&nbsp;<code>.htaccess<\/code>&nbsp;is critical to your web server. Before we begin, we need to allow Apache to read&nbsp;<code>.htaccess<\/code>&nbsp;files located under the&nbsp;<code>\/var\/www\/html<\/code>&nbsp;directory.<\/p>\n\n\n\n<p>You can do this by editing&nbsp;<code>httpd.conf<\/code>&nbsp;file:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo nano \/etc\/httpd\/conf\/httpd.conf\n\n<\/pre><\/div>\n\n\n<p>Find the section&nbsp;<code>&lt;directory \/var\/www\/html&gt;<\/code>&nbsp;and change&nbsp;<strong>AllowOverride None<\/strong>&nbsp;to&nbsp;<strong>AllowOverride All<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n &amp;lt;Directory \/var\/www\/html&gt;\n    AllowOverride All\n &amp;lt;\/Directory&gt;\n\n<\/pre><\/div>\n\n\n<p>Save and exit.<\/p>\n\n\n\n<p>Now restart Apache to put the change into effect:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo systemctl restart httpd\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<p>\u7b2c\u4e00\u6b65\u5927\u6982\u610f\u601d\u5c31\u662f\u4fee\u6539\/etc\/httpd\/conf.modules.d\/00-base.conf\u6587\u4ef6\uff0c\u5c06<\/p>\n\n\n\n<p>LoadModule rewrite_module modules\/mod_rewrite.so<\/p>\n\n\n\n<p>\u8fd9\u4e00\u53e5\u524d\u7684\u6ce8\u91ca\u53d6\u6d88\uff0c\u5982\u679c\u6ca1\u6709\u8fd9\u4e00\u53e5\u7684\u8bdd\u76f4\u63a5\u52a0\u4e0a\u5373\u53ef<\/p>\n\n\n\n<p>\u6211\u770b\u4e86\u4e00\u4e0b\uff0c\u6211\u7684\u662f\u8fd9\u4e2a\u6587\u4ef6\u91cc\u7684\u8fd9\u90e8\u5206\u662f\u6b63\u5e38\u7684\uff0c\u5c31\u6ca1\u6709\u8c03\u6574\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u7136\u540e\u6211\u6309\u7167\u7b2c\u4e8c\u6b65\u8c03\u6574\u4e86\u4e00\u4e0b\uff0c\u7f51\u7ad9\u663e\u793a\u5c31\u6b63\u5e38\u4e86\uff0c\u4e0b\u9762\u662f\u8c03\u6574\u6b65\u9aa4<\/p>\n\n\n\n<p>\u4fee\u6539\/etc\/httpd\/conf\/httpd.conf\u6587\u4ef6\uff0c\u627e\u5230\u5982\u4e0b\u7c7b\u578b\u7684\u6587\u672c\uff0c\u4fee\u6539\u4e3a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n &amp;lt;Directory \/var\/www\/html&gt;\n    AllowOverride All\n &amp;lt;\/Directory&gt;\n<\/pre><\/div>\n\n\n<p>\u4fee\u6539\u5b8c\u4ee5\u540e\u91cd\u542fapache\u5373\u53ef<\/p>\n\n\n\n<p>sudo systemctl restart httpd<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u6587\u672c\u4fee\u6539\u7684\u65b9\u6cd5\u53ef\u4ee5\u53c2\u8003\u6211\u7684<a href=\"http:\/\/www.danios.com\/vim\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u5173\u4e8evim\u914d\u7f6e\u7684\u6587\u7ae0<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u6b64\u5904\u7406\u65b9\u6848\u4ec5\u662f\u4e2a\u4eba\u73af\u5883\u7684\u5904\u7406\u65b9\u6848\uff0c\u4ec5\u4f9b\u53c2\u8003\uff0c\u6709\u95ee\u9898\u7684\u8bdd\u4e5f\u53ef\u4ee5\u7559\u8a00\u8ba8\u8bba<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u6574\u7406\u4e86\u4e00\u4e0b\u7f51\u7ad9\uff0c\u60f3\u5c06\u56fa\u5b9a\u94fe\u63a5\u8c03\u6574\u4e00\u4e0b\uff0c\u4f46\u662f\u53c8\u51fa\u73b0\u4e86\u53ea\u80fd\u8bbf\u95ee\u9996\u9875\uff0c\u5176\u4ed6\u5b50\u9875\u9762\u63d0\u793a\u65e0\u6cd5\u8bbf\u95ee\u7684\u95ee\u9898\uff0c\u8054\u60f3\u5230\u4e4b\u524d\u4e5f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-554","post","type-post","status-publish","format-standard","hentry","category-linux"],"aioseo_notices":[],"views":178,"_links":{"self":[{"href":"https:\/\/www.oceansource.cc\/index.php?rest_route=\/wp\/v2\/posts\/554","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oceansource.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oceansource.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oceansource.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oceansource.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=554"}],"version-history":[{"count":1,"href":"https:\/\/www.oceansource.cc\/index.php?rest_route=\/wp\/v2\/posts\/554\/revisions"}],"predecessor-version":[{"id":556,"href":"https:\/\/www.oceansource.cc\/index.php?rest_route=\/wp\/v2\/posts\/554\/revisions\/556"}],"wp:attachment":[{"href":"https:\/\/www.oceansource.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=554"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oceansource.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=554"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oceansource.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}