Skip to content

refactor: suppress docroot warning when .htaccess file is present, fixes #7345 - #7349

Closed
stasadev wants to merge 1 commit into
ddev:mainfrom
stasadev:20250506_stasadev_docroot_warning
Closed

stasadev wants to merge 1 commit into
ddev:mainfrom
stasadev:20250506_stasadev_docroot_warning

Conversation

@stasadev

@stasadev stasadev commented Jun 3, 2025 •

Copy link
Copy Markdown
Member

The Issue

How This PR Solves The Issue

Doesn't show warning for apache2 if there is .htaccess file in the docroot directory.

Example file is https://github.com/silverstripeltd/demo-project/blob/master/.htaccess

I decided not to check the contents of the .htaccess file because the main warning goal is already met.
People who don't understand docroot might set it to a random folder that doesn't have the right files.

Manual Testing Instructions

$ mkdir docroot-htaccess && cd docroot-htaccess
$ ddev config --webserver-type=nginx-fpm
$ touch .htaccess
$ ddev start

Starting docroot-htaccess... 
The index.php or index.html does not yet exist at this path:
/home/stas/tmp/docroot-htaccess/index.*
You may get 403 errors 'permission denied' from the browser until it does.
If the webserver rewrites to a different docroot, this warning may not apply.
Ignore if a later action (like 'ddev composer create-project') will create it. 

$ ddev config --webserver-type=apache-fpm
$ ddev start

Starting docroot-htaccess...
(no warning)
...

Automated Testing Overview

Release/Deployment Notes

@github-actions

github-actions Bot commented Jun 3, 2025

Copy link
Copy Markdown

@n8-dev

n8-dev commented Jun 4, 2025

Copy link
Copy Markdown

I don't have time to check this right now, but this looks pretty good, thank you for trying a solution 😄

@tyler36 tyler36 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as described; warning does not appear when .htaccess file is present

Test DDEV v1.24.6

$ ddev -v
ddev version v1.24.6
$ ddev config --webserver-type=apache-fpm
$ touch .htaccess
$ ddev start
...
The index.php or index.html does not yet exist in
/home/user47/tmp/docroot-htaccess/index.*
so you may get 403 errors 'permission denied' from the browser until it does.
Don't worry about this if a later action 
(like `ddev composer install`) will create the file.
...
Successfully started docroot-htaccess 

Test PR

$ ddev -v
ddev version v1.24.6-12-gcffa66a35
$ ddev start
...
(no warning)
Successfully started docroot-htaccess 

@rfay

rfay commented Jun 8, 2025

Copy link
Copy Markdown
Member

Could you please add to the OP to explain why we should skip the warning if a .htaccess is in the docroot?

@n8-dev

n8-dev commented Jun 10, 2025

Copy link
Copy Markdown

Sorry @rfay do you mean on this PR? Or this issue? #7345

@rfay

rfay commented Jun 10, 2025

Copy link
Copy Markdown
Member

@n8-dev I meant on this PR.

@rfay rfay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we absolutely respect the Silverstripe community's request for this general feature, I'm not convinced this is the right solution. What's going on with silverstripe seems to be a very unusual server-side configuration, and I don't think it makes sense to have DDEV jump through hoops to solve a problem like that.

I also recognize that this is a pretty simple PR, but it's still likely to have unexpected consequences.

I guess as suggested in #7345 the way to solve it would be adding configuration to say "don't warn". But even that seems like jumping through modest hoops to solve a complexity introduced by one CMS and not even in the context of DDEV.

@stasadev

Copy link
Copy Markdown
Member Author

Closing to move the conversation back to the issue.

@stasadev stasadev closed this Jun 11, 2025
@stasadev
stasadev deleted the 20250506_stasadev_docroot_warning branch June 11, 2025 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants