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

dev/core#913 - update autogenerated .htaccess for apache 2.4 #14158

Merged
merged 1 commit into from
May 25, 2019

Conversation

demeritcowboy
Copy link
Contributor

Overview

See https://lab.civicrm.org/dev/core/issues/913

Before

The current autogenerated .htaccess is for apache 2.2. It happens to work on apache 2.4 because it gives an internal error, but that's obviously not what was intended. It may also happen to work on apache 2.4 if mod_access_compat happens to be installed.

After

Works on apache 2.4 with no log errors. Falls back to current behavior if it can't tell if it's apache 2.4 or higher.

@civibot
Copy link

civibot bot commented Apr 30, 2019

(Standard links)

Copy link
Contributor

@pfigel pfigel left a comment

Choose a reason for hiding this comment

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

You can use something like this to have a single .htaccess that is compatible with both versions of apache:

# Apache 2.2
<IfModule !authz_core_module>
  Order Deny,Allow
  Deny from all
</IfModule>

# Apache 2.4+
<IfModule authz_core_module>
  <RequireAll>
    Require all denied
  </RequireAll>
</IfModule>

This has the advantage of continuing to work if installs move back and forth between apache versions (or if version detection fails).

(Based on an example in .htaccess made easy.)

@demeritcowboy
Copy link
Contributor Author

Thanks! I'll take a look. Makes sense. The Order is backwards but it's because in that example they are doing something slightly different. Similarly the RequireAll isn't needed. Anyway I have a 2.2 and 2.4 so I'll test it out.

@demeritcowboy
Copy link
Contributor Author

Oops. Somehow that closed the PR.

@demeritcowboy demeritcowboy reopened this May 1, 2019
Copy link
Contributor

@pfigel pfigel left a comment

Choose a reason for hiding this comment

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

Looks great now, thanks @demeritcowboy!

(CiviCRM Review Template WORD-1.2)

  • General standards
    • (r-explain) PASS
    • (r-user) PASS: Fixes a bug with little user impact.
    • (r-doc) PASS
    • (r-run) PASS: Config blocked access when tested against apache 2.2 and 2.4.
  • Developer standards

@demeritcowboy
Copy link
Contributor Author

Thanks for reviewing @pfigel

@eileenmcnaughton
Copy link
Contributor

reviewing based on @pfigel review

@eileenmcnaughton eileenmcnaughton merged commit 2348546 into civicrm:master May 25, 2019
@demeritcowboy demeritcowboy deleted the deny-for-real branch May 28, 2019 03:46
@edvanleeuwen
Copy link

@demeritcowboy
Copy link
Contributor Author

@edvanleeuwen Ahh I never saw that. I see you had some technical trouble getting a pull request posted back then - it is pretty tricky. You can see farther up here I accidentally closed this one in the middle somehow and I'm still not sure how I did that. I don't know if you asked in chat.civicrm.org back then but in future you can also ask there which is sometimes helpful for those technical hurdles.

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

Successfully merging this pull request may close these issues.

4 participants