官方文档  https://codex.wordpress.org/Nginx 有说了:

  • With Nginx there is no directory-level configuration file like Apache’s .htaccess or IIS’s web.config files. All configuration has to be done at the server level by an administrator, and WordPress cannot modify the configuration, like it can with Apache or IIS.
  • Pretty Permalinks functionality is slightly different when running Nginx.
  • Since Nginx does not have .htaccess-type capability and WordPress cannot automatically modify the server configuration for you, it cannot generate the rewrite rules for you.
  • Without modifications to your install, “index.php” will be added to your Permalinks. (There are ways to mitigate this with plugins (see below) and/or adding custom code to your child theme’s functions.php.)
  • However, if you do want to have some (limited) .htaccess capability, it is technically possible to do add by installing the htscanner PECL extension for PHP. (However, this is not a perfect solution so be sure to test and debug thoroughly before using on a live site.)

简单的理解,nginx没有像apache那样有 .htaccess 这个文件来配置目录层级,apahce上的永久链接在nginx上的使用方法会有些不同。但尴尬的是这篇官方文档并未指明解决方案。

通过搜索引擎搜索:Permalinks wordpress nginx, 在CSDN中找到这篇文章:https://blog.csdn.net/weixin_43690347/article/details/84038172

按照文章里说的步骤配置: /etc/nginx/conf.d/default.conf 的 location / 后,

if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
if (!-f $request_filename){
rewrite (.*) /index.php;


Leave a Reply

Your email address will not be published.