<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>伪静态 on 蛋蛋忧桑</title><link>https://dandansad.com/tags/%E4%BC%AA%E9%9D%99%E6%80%81/</link><description>Recent content in 伪静态 on 蛋蛋忧桑</description><generator>Hugo -- gohugo.io</generator><language>zh</language><lastBuildDate>Sun, 02 Mar 2025 01:30:16 +0800</lastBuildDate><atom:link href="https://dandansad.com/tags/%E4%BC%AA%E9%9D%99%E6%80%81/index.xml" rel="self" type="application/rss+xml"/><item><title>伪静态</title><link>https://dandansad.com/2025/03/02/%E4%BC%AA%E9%9D%99%E6%80%81/</link><pubDate>Sun, 02 Mar 2025 01:30:16 +0800</pubDate><guid>https://dandansad.com/2025/03/02/%E4%BC%AA%E9%9D%99%E6%80%81/</guid><description>
 &lt;blockquote&gt;
 &lt;p&gt;本文为人工智能问答记录，内容仅供参考，可能存在错误信息。&lt;/p&gt;

 &lt;/blockquote&gt;
&lt;h2 id="一什么是伪静态"&gt;&lt;a href="#%e4%b8%80%e4%bb%80%e4%b9%88%e6%98%af%e4%bc%aa%e9%9d%99%e6%80%81" class="header-anchor"&gt;&lt;/a&gt;一、什么是伪静态？
&lt;/h2&gt;&lt;p&gt;&lt;strong&gt;伪静态&lt;/strong&gt;（Pseudo-static）是一种通过 URL 重写技术，将动态 URL 转换为看起来像静态 URL 的技术。它的目的是让 URL 更加友好、易读，同时提升搜索引擎优化（SEO）效果。以下是关于伪静态的详细解释：&lt;/p&gt;
&lt;h3 id="1-动态-url-和静态-url"&gt;&lt;a href="#1-%e5%8a%a8%e6%80%81-url-%e5%92%8c%e9%9d%99%e6%80%81-url" class="header-anchor"&gt;&lt;/a&gt;1. &lt;strong&gt;动态 URL 和静态 URL&lt;/strong&gt;
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;动态 URL&lt;/strong&gt;：&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;动态 URL 通常包含查询参数，用于传递数据给服务器。例如：&lt;code&gt;https://example.com/index.php?p=123&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;这种 URL 对用户不友好，且不利于 SEO。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;静态 URL&lt;/strong&gt;：&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;静态 URL 看起来像是一个具体的文件路径，例如：&lt;code&gt;https://example.com/about-us.html&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;这种 URL 更简洁、易读，且对 SEO 更友好。&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="2-伪静态的作用"&gt;&lt;a href="#2-%e4%bc%aa%e9%9d%99%e6%80%81%e7%9a%84%e4%bd%9c%e7%94%a8" class="header-anchor"&gt;&lt;/a&gt;2. &lt;strong&gt;伪静态的作用&lt;/strong&gt;
&lt;/h3&gt;&lt;p&gt;伪静态通过 URL 重写技术，将动态 URL 转换为静态 URL 的形式，但实际上仍然是动态生成的页面。例如：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;动态 URL：&lt;code&gt;https://example.com/index.php?p=123&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;伪静态 URL：&lt;code&gt;https://example.com/my-post-title&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;尽管第二个 URL 看起来像是一个静态页面，但实际上它仍然是由服务器动态生成的（例如通过 PHP 脚本处理）。&lt;/p&gt;
&lt;h3 id="3-伪静态的实现原理"&gt;&lt;a href="#3-%e4%bc%aa%e9%9d%99%e6%80%81%e7%9a%84%e5%ae%9e%e7%8e%b0%e5%8e%9f%e7%90%86" class="header-anchor"&gt;&lt;/a&gt;3. &lt;strong&gt;伪静态的实现原理&lt;/strong&gt;
&lt;/h3&gt;&lt;p&gt;伪静态的实现依赖于服务器的 URL 重写功能：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Apache 服务器&lt;/strong&gt;：&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;使用 &lt;code&gt;.htaccess&lt;/code&gt; 文件和 &lt;code&gt;mod_rewrite&lt;/code&gt; 模块。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;例如，WordPress 的伪静态规则：&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;RewriteEngine On&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;RewriteBase /&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;RewriteRule ^index.php$ - [L]&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;RewriteCond %{REQUEST_FILENAME} !-f&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;RewriteCond %{REQUEST_FILENAME} !-d&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;RewriteRule . /index.php [L]&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;这段代码的作用是将所有请求重写到 &lt;code&gt;index.php&lt;/code&gt;，由 WordPress 处理 URL 路由。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Nginx 服务器&lt;/strong&gt;：&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;使用 &lt;code&gt;rewrite&lt;/code&gt; 指令。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;例如，WordPress 的伪静态规则：&lt;code&gt;location / { try_files $uri $uri/ /index.php?$args; }&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;这段代码的作用是尝试访问与 URL 对应的文件或目录，如果不存在，则将请求重写到 &lt;code&gt;index.php&lt;/code&gt;。&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="4-伪静态的优点"&gt;&lt;a href="#4-%e4%bc%aa%e9%9d%99%e6%80%81%e7%9a%84%e4%bc%98%e7%82%b9" class="header-anchor"&gt;&lt;/a&gt;4. &lt;strong&gt;伪静态的优点&lt;/strong&gt;
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;URL 友好&lt;/strong&gt;：&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;伪静态 URL 更简洁、易读，对用户更友好。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;SEO 优化&lt;/strong&gt;：&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;搜索引擎更喜欢静态 URL，伪静态 URL 可以提高网站的搜索排名。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;隐藏技术细节&lt;/strong&gt;：&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;伪静态 URL 隐藏了服务器端的技术细节（如 &lt;code&gt;.php&lt;/code&gt; 或查询参数），使 URL 更简洁。&lt;/p&gt;
&lt;h3 id="5-伪静态的缺点"&gt;&lt;a href="#5-%e4%bc%aa%e9%9d%99%e6%80%81%e7%9a%84%e7%bc%ba%e7%82%b9" class="header-anchor"&gt;&lt;/a&gt;5. &lt;strong&gt;伪静态的缺点&lt;/strong&gt;
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;服务器性能&lt;/strong&gt;：&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;伪静态 URL 需要通过服务器动态生成内容，可能会增加服务器的负载。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;配置复杂&lt;/strong&gt;：&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;需要正确配置服务器的 URL 重写规则，否则可能导致 404 错误。&lt;/p&gt;
&lt;h3 id="6-伪静态的应用场景"&gt;&lt;a href="#6-%e4%bc%aa%e9%9d%99%e6%80%81%e7%9a%84%e5%ba%94%e7%94%a8%e5%9c%ba%e6%99%af" class="header-anchor"&gt;&lt;/a&gt;6. &lt;strong&gt;伪静态的应用场景&lt;/strong&gt;
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;内容管理系统（CMS）&lt;/strong&gt;：&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;如 WordPress、Joomla、Drupal 等，通常使用伪静态 URL 来优化 SEO 和用户体验。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;电子商务网站&lt;/strong&gt;：&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;伪静态 URL 可以使产品页面 URL 更友好，提升用户体验和搜索排名。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;博客和新闻网站&lt;/strong&gt;：&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;伪静态 URL 可以使文章链接更简洁、易读。&lt;/p&gt;
&lt;h3 id="7-伪静态与真静态的区别"&gt;&lt;a href="#7-%e4%bc%aa%e9%9d%99%e6%80%81%e4%b8%8e%e7%9c%9f%e9%9d%99%e6%80%81%e7%9a%84%e5%8c%ba%e5%88%ab" class="header-anchor"&gt;&lt;/a&gt;7. &lt;strong&gt;伪静态与真静态的区别&lt;/strong&gt;
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;伪静态&lt;/strong&gt;：&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;URL 看起来像静态文件，但实际上是动态生成的。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;例如：&lt;code&gt;https://example.com/my-post-title&lt;/code&gt;（由 PHP 动态生成）。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;真静态&lt;/strong&gt;：&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;URL 对应一个实际的静态文件（如 HTML 文件）。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;例如：&lt;code&gt;https://example.com/about-us.html&lt;/code&gt;（直接访问一个 HTML 文件）。&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="8-如何在-wordpress-中启用伪静态"&gt;&lt;a href="#8-%e5%a6%82%e4%bd%95%e5%9c%a8-wordpress-%e4%b8%ad%e5%90%af%e7%94%a8%e4%bc%aa%e9%9d%99%e6%80%81" class="header-anchor"&gt;&lt;/a&gt;8. &lt;strong&gt;如何在 WordPress 中启用伪静态&lt;/strong&gt;
&lt;/h3&gt;&lt;p&gt;在 WordPress 中，伪静态通常通过“固定链接”功能实现：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;登录 WordPress 后台。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;进入 &lt;strong&gt;设置 &amp;gt; 固定链接&lt;/strong&gt;。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;选择一个伪静态 URL 结构，例如：&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;https://example.com/%postname%/&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;https://example.com/category/%postname%/&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;保存设置。&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;如果服务器是 Nginx，需要手动添加重写规则（如 &lt;code&gt;try_files&lt;/code&gt;）；如果是 Apache，WordPress 会自动生成 &lt;code&gt;.htaccess&lt;/code&gt; 文件。&lt;/p&gt;
&lt;h3 id="9-总结"&gt;&lt;a href="#9-%e6%80%bb%e7%bb%93" class="header-anchor"&gt;&lt;/a&gt;9. &lt;strong&gt;总结&lt;/strong&gt;
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;伪静态是一种将动态 URL 转换为静态 URL 的技术，使 URL 更友好、更利于 SEO。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;它通过服务器的 URL 重写功能实现（如 Apache 的 &lt;code&gt;.htaccess&lt;/code&gt; 或 Nginx 的 &lt;code&gt;rewrite&lt;/code&gt; 指令）。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;伪静态广泛应用于 CMS、电子商务网站和博客等场景。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;在 WordPress 中，伪静态通过“固定链接”功能启用，但需要确保服务器配置正确。&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="二但是用户访问的不就是httpsexamplecomcategorypostname这样类型的网址吗不是访问的httpsexamplecomindexphpp123啊"&gt;&lt;a href="#%e4%ba%8c%e4%bd%86%e6%98%af%e7%94%a8%e6%88%b7%e8%ae%bf%e9%97%ae%e7%9a%84%e4%b8%8d%e5%b0%b1%e6%98%afhttpsexamplecomcategorypostname%e8%bf%99%e6%a0%b7%e7%b1%bb%e5%9e%8b%e7%9a%84%e7%bd%91%e5%9d%80%e5%90%97%e4%b8%8d%e6%98%af%e8%ae%bf%e9%97%ae%e7%9a%84httpsexamplecomindexphpp123%e5%95%8a" class="header-anchor"&gt;&lt;/a&gt;二、但是用户访问的不就是https://example.com/category/%postname%/这样类型的网址吗，不是访问的https://example.com/index.php?p=123啊
&lt;/h2&gt;&lt;p&gt;你的问题非常好！确实，用户访问的是类似 &lt;code&gt;https://example.com/category/postname/&lt;/code&gt; 这样的网址，而不是 &lt;code&gt;https://example.com/index.php?p=123&lt;/code&gt;。这里的关键在于 &lt;strong&gt;URL 重写&lt;/strong&gt; 和 &lt;strong&gt;服务器如何处理这些 URL&lt;/strong&gt;。以下是对这个问题的详细解释：&lt;/p&gt;
&lt;h3 id="1-用户访问的-url"&gt;&lt;a href="#1-%e7%94%a8%e6%88%b7%e8%ae%bf%e9%97%ae%e7%9a%84-url" class="header-anchor"&gt;&lt;/a&gt;1. &lt;strong&gt;用户访问的 URL&lt;/strong&gt;
&lt;/h3&gt;&lt;p&gt;当用户访问 &lt;code&gt;https://example.com/category/postname/&lt;/code&gt; 时，浏览器会向服务器发送一个请求，要求获取这个 URL 对应的内容。&lt;/p&gt;
&lt;h3 id="2-服务器的默认行为"&gt;&lt;a href="#2-%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e9%bb%98%e8%ae%a4%e8%a1%8c%e4%b8%ba" class="header-anchor"&gt;&lt;/a&gt;2. &lt;strong&gt;服务器的默认行为&lt;/strong&gt;
&lt;/h3&gt;&lt;p&gt;如果没有配置 URL 重写规则，服务器会尝试直接查找与 URL 路径对应的文件或目录。例如：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;服务器会尝试查找 &lt;code&gt;/category/postname/&lt;/code&gt; 目录或文件。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;如果找不到对应的文件或目录，服务器会返回 &lt;strong&gt;404 错误&lt;/strong&gt;。&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="3-wordpress-的工作原理"&gt;&lt;a href="#3-wordpress-%e7%9a%84%e5%b7%a5%e4%bd%9c%e5%8e%9f%e7%90%86" class="header-anchor"&gt;&lt;/a&gt;3. &lt;strong&gt;WordPress 的工作原理&lt;/strong&gt;
&lt;/h3&gt;&lt;p&gt;WordPress 使用“前端控制器”模式，即所有的请求都由 &lt;code&gt;index.php&lt;/code&gt; 处理。&lt;code&gt;index.php&lt;/code&gt; 会根据 URL 路径决定显示哪个页面或文章。为了实现这一点，WordPress 需要将所有请求重写到 &lt;code&gt;index.php&lt;/code&gt;。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;动态 URL&lt;/strong&gt;：&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;默认情况下，WordPress 使用动态 URL（如 &lt;code&gt;https://example.com/index.php?p=123&lt;/code&gt;），这种 URL 直接传递给 &lt;code&gt;index.php&lt;/code&gt;，因此不需要重写规则。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;固定链接（伪静态 URL）&lt;/strong&gt;：&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;当你启用固定链接（如 &lt;code&gt;https://example.com/category/postname/&lt;/code&gt;）时，URL 路径不再直接对应查询参数，因此需要重写规则将所有请求重写到 &lt;code&gt;index.php&lt;/code&gt;。&lt;/p&gt;
&lt;h3 id="4-url-重写的作用"&gt;&lt;a href="#4-url-%e9%87%8d%e5%86%99%e7%9a%84%e4%bd%9c%e7%94%a8" class="header-anchor"&gt;&lt;/a&gt;4. &lt;strong&gt;URL 重写的作用&lt;/strong&gt;
&lt;/h3&gt;&lt;p&gt;URL 重写规则的作用是告诉服务器：“如果请求的 URL 路径不对应任何实际文件或目录，就将请求交给 &lt;code&gt;index.php&lt;/code&gt; 处理。” 这样，WordPress 才能根据 URL 路径动态生成内容。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Apache 服务器&lt;/strong&gt;：&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;使用 &lt;code&gt;.htaccess&lt;/code&gt; 文件中的 &lt;code&gt;mod_rewrite&lt;/code&gt; 模块。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;例如，WordPress 生成的 &lt;code&gt;.htaccess&lt;/code&gt; 文件内容：&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;IfModule mod_rewrite.c&amp;gt; &lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;RewriteEngine On &lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;RewriteBase / &lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;RewriteRule ^index\.php$ - [L] &lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;RewriteCond %{REQUEST_FILENAME} !-f &lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;RewriteCond %{REQUEST_FILENAME} !-d &lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;RewriteRule . /index.php [L] &lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;/IfModule&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;这段代码的作用是将所有不匹配实际文件或目录的请求重写到 &lt;code&gt;index.php&lt;/code&gt;。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Nginx 服务器&lt;/strong&gt;：&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;使用 &lt;code&gt;rewrite&lt;/code&gt; 指令。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;例如，WordPress 的 Nginx 重写规则：&lt;code&gt;location / { try_files $uri $uri/ /index.php?$args; }&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;这段代码的作用是尝试访问与 URL 对应的文件或目录，如果不存在，则将请求重写到 &lt;code&gt;index.php&lt;/code&gt;。&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="5-用户访问的-url-如何被处理"&gt;&lt;a href="#5-%e7%94%a8%e6%88%b7%e8%ae%bf%e9%97%ae%e7%9a%84-url-%e5%a6%82%e4%bd%95%e8%a2%ab%e5%a4%84%e7%90%86" class="header-anchor"&gt;&lt;/a&gt;5. &lt;strong&gt;用户访问的 URL 如何被处理&lt;/strong&gt;
&lt;/h3&gt;&lt;p&gt;当用户访问 &lt;code&gt;https://example.com/category/postname/&lt;/code&gt; 时，服务器的处理流程如下：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;服务器接收到请求，尝试查找 &lt;code&gt;/category/postname/&lt;/code&gt; 目录或文件。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;如果没有找到对应的文件或目录，服务器会根据重写规则将请求重写到 &lt;code&gt;index.php&lt;/code&gt;。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;index.php&lt;/code&gt; 会根据 URL 路径（&lt;code&gt;/category/postname/&lt;/code&gt;）决定显示哪个页面或文章。&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="6-为什么用户看不到"&gt;&lt;a href="#6-%e4%b8%ba%e4%bb%80%e4%b9%88%e7%94%a8%e6%88%b7%e7%9c%8b%e4%b8%8d%e5%88%b0" class="header-anchor"&gt;&lt;/a&gt;6. &lt;strong&gt;为什么用户看不到 &lt;code&gt;index.php&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;URL 重写&lt;/strong&gt;：&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;URL 重写规则将所有请求重写到 &lt;code&gt;index.php&lt;/code&gt;，但浏览器地址栏中的 URL 不会改变。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;例如，用户访问 &lt;code&gt;https://example.com/category/postname/&lt;/code&gt;，服务器内部将请求重写到 &lt;code&gt;index.php&lt;/code&gt;，但用户仍然看到 &lt;code&gt;https://example.com/category/postname/&lt;/code&gt;。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;前端控制器模式&lt;/strong&gt;：&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;WordPress 使用前端控制器模式，所有的请求都由 &lt;code&gt;index.php&lt;/code&gt; 处理，但用户看不到这一点。&lt;/p&gt;
&lt;h3 id="7-总结"&gt;&lt;a href="#7-%e6%80%bb%e7%bb%93" class="header-anchor"&gt;&lt;/a&gt;7. &lt;strong&gt;总结&lt;/strong&gt;
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;用户访问的是伪静态 URL（如 &lt;code&gt;https://example.com/category/postname/&lt;/code&gt;），而不是动态 URL（如 &lt;code&gt;https://example.com/index.php?p=123&lt;/code&gt;）。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;服务器通过 URL 重写规则将所有请求重写到 &lt;code&gt;index.php&lt;/code&gt;，由 WordPress 根据 URL 路径动态生成内容。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;URL 重写规则的作用是让伪静态 URL 能够正常工作，同时保持 URL 的友好性和 SEO 优势。&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;通过这种方式，用户看到的 URL 是简洁、友好的，而服务器内部仍然使用动态生成的内容。这就是伪静态的核心原理。&lt;/p&gt;</description></item></channel></rss>