大网数据广告活动
网站运营与故障问答

What is `wp-cli.yml` for in the public_html folder?

· 52CE 我爱测

I recently signed up a hosting package, and installed WordPress from the control panel. I noticed there is wp-cli.yml in the web root folder. The file contains: apache_modules: - mod_rewrite Can I ask what is it for? Is it a good…

问题原文

原帖链接 · Stickers · CC BY-SA 3.0

I recently signed up a hosting package, and installed WordPress from the control panel. I noticed there is wp-cli.yml in the web root folder. The file contains:

apache_modules:
    - mod_rewrite

Can I ask what is it for? Is it a good idea to leave it there even if I might never use it?

社区高分解答

原帖链接 · SherylHohman · CC BY-SA 4.0

It is used by wp-cli, the command line interface for WordPress.
The wp-cli.yml is where you set configuration values, related to your website, for wp-cli.php to use.
https://make.wordpress.org/cli/handbook/config/

For example, to update "pretty links" from the command line (wp rewrite flush), the wp-cli.yml (or a config.yml) file is necessary for the command to work properly.
From the docs:

wp rewrite flush flushes rewrite rules.
Resets WordPress’ rewrite rules based on registered post types, etc.
To regenerate a .htaccess file with WP-CLI, you’ll need to add the mod_rewrite module to your wp-cli.yml or config.yml.
For example:
apache_modules: - mod_rewrite

Flushing and Re-saving permalinks is often needed when changing themes, or if you change the installation folder for your WordPress files.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2018-02-09)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。