Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrite flush --hard should create .htaccess if it does not exist #46

Open
tomsommer opened this issue Oct 7, 2020 · 5 comments
Open

Comments

@tomsommer
Copy link

Right now flush --hard returns success, but it actually fails if there is no .htaccess file.

flush --hard should create .htaccess if it does not exist

@janw-me
Copy link
Member

janw-me commented May 29, 2022

A candidate for good-first-issue ?

@schlessera
Copy link
Member

Yes, this seems like a bug.

However, the behavior would need to be aware of Apache vs Nginx as well. Creating an .htaccess file on an Nginx installation will not do anything. This should then throw an error too. The question is then whether we can reliably detect the hosting configuration that make use of a .htaccess file...?

@tomsommer
Copy link
Author

tomsommer commented May 30, 2022

Maybe only do it if apache_modules: mod_rewrite. If you plan on writing to .htaccess, you should simply create it before doing so?

a touch() call before

flush_rewrite_rules( Utils\get_flag_value( $assoc_args, 'hard' ) );
would do it

@schlessera schlessera changed the title flush --hard should create .htaccess if it does not exist. rewrite flush --hard should create .htaccess if it does not exist Jun 2, 2022
@thomasplevy
Copy link

As closely as I can tell this is currently working as desired.

After installing WP and configuring permalinks then deleting .htaccess and the running wp rewrite flush --hard the .htaccess file is recreated and exits with 0.

@TremiDkhar
Copy link

Running rewrite flush --hard does create the .htaccess file if it doesn't already exist. I have run this command on both my local and remote setups, and I can confirm that it works as expected.

The only way that I can reproduce the issue is by removing the following lines from the ~/.wp-cli/config.yml, which is needed according to the command README.MD

apache_modules:
  - mod_rewrite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants