5

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?

  • 1
    I have a hunch its a file that got installed from you installing wordpress. I guess this because the filename starts with wp which stands for wordpress. If I'm correct, then I'd just leave the file alone. – Mike Feb 9 '18 at 22:56
3

It’s a file that your hosting company is using to help them manage the availability of and updates to the WordPress Command Line Interface. It’s supposed to be there, don’t mess with it.

4

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.