Skip to content

Allow a .htaccess-lando to override .htaccess #38

Open

Description

@web-assistant

I'm trying to override the .htaccess file as instructed in https://docs.lando.dev/config/apache.html#configuration. Adding .htaccess-lando next to the Drupal root .htaccess file doesn't do anything. I have tried rebuilding and also tried adding the custom httpd.conf file taken from https://github.com/lando/lando/tree/master/plugins/lando-services/services/apache. Any ideas how I can get this working?

screen

Running Lando v3.0.3 on Windows 10.

name: thingymajig
recipe: drupal7
config:
  php: '7.2'
  via: apache
  webroot: web
  database: mariadb
  drush: ^8
  xdebug: false
  config:
    php: .lando/.lando.php.ini
    database: .lando/.lando.mysql.cnf
    server: .lando/httpd.conf
    vhosts: .lando/default.conf

proxy:
  appserver:
    - thingymajig.lndo.site
    - www.thingymajig.lndo.site
  mailhog:
    - mail.thingymajig.lndo.site
  pma:
    - pma.thingymajig.lndo.site
  adminer:
    - adminer.thingymajig.lndo.site

services:
  database:
    creds:
      database: thingymajig
      user: thingymabob
      password: easylike123
  appserver:
    overrides:
      environment:
        # Support debugging Drush with XDEBUG.
        PHP_IDE_CONFIG: "serverName=appserver"
  mailhog:
    type: mailhog
    hogfrom:
      - appserver
    portforward: true
  pma:
    type: phpmyadmin
    hosts:
      - database
  adminer:
    type: compose
    services:
      image: dehy/adminer
      command: /bin/s6-svscan /etc/services.d
    portforward: true

tooling:
  xon:
    service: appserver
    description: Enable xdebug for apache.
    cmd: "docker-php-ext-enable xdebug && /etc/init.d/apache2 reload"
    user: root
  xoff:
    service: appserver
    description: Disable xdebug for apache.
    cmd: "rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && /etc/init.d/apache2 reload"
    user: root

excludes:
  - .idea
  - .git

Activity

  1. added
    bug
    on May 21, 2020
  2. rabauss commented on May 22, 2020

    @rabauss

    How does your httpd.conf look like?
    I guess, it should contain the following line like in the example:
    https://github.com/lando/lando/blob/3802a60012fa1938ff3cf2f647c4ad7e1baf72a1/examples/apache/config/httpd.conf#L455

    EDIT: I see you took them from the services. Could be a bug in the config - but I've never use that feature before.

  3. web-assistant commented on May 22, 2020

    @web-assistant
    Author

    @rabauss I changed the httpd.conf to the one in the link you provided but still get the same issue. The docs say that the override should work with the httpd.conf shipped with Lando, though if I have the .htaccess-lando file with no custom httpd.conf it still doesn't work. I'm rebuilding Lando each time.

  4. hanoii commented on May 24, 2020

    @hanoii

    Yes, this is not working for me either. Looking at the /etc/apache2/apache2.conf inside the container it doesn't have .htaccess-lando on it

  5. removed their assignment
    on May 26, 2020
  6. anacolautti commented on Jun 2, 2020

    @anacolautti

    Hi everyone!
    While the experts figure this out (I wish I could help, but actually I know very little of about the subject) I have a temporal fix for anyone who might need this right away.
    I was inspired by the issue that enabled this feature to begin with, I tried actually applying their code and it didn't work for me.

    This variation of their code did, though:

    if [ -e /etc/apache2/apache2.conf ]; then
        if ! grep -e 'AccessFileName .htaccess-lando .htaccess' /etc/apache2/apache2.conf >/dev/null; then
            # force apache to use the .htaccess-lando file
            eval "sed -i 's/AccessFileName .htaccess/AccessFileName .htaccess-lando/g' /etc/apache2/apache2.conf"
        fi
    fi
    

    I'm replacing the line in my Apache service that calls my client's .htaccess and calling the file .htaccess-lando instead.
    I know this is just temporary, until someone fixes this for real, but in took me a few hours to get this working and I thought I could spare them for someone else.

    Just remember to add this code to a script, and call it from your .lando.yml file at the services key like this:

    [...]
    services:
      myservice:
        build_as_root:
          cmd: /path/temporal_apache_patch.sh
    [...]
    
    

    Keep being awesome!

  7. stale commented on Apr 27, 2021

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions and please check out this if you are wondering why we auto close issues.

  8. f-liva commented on Sep 10, 2021

    @f-liva

    When will this hotfix be implemented natively?

  9. stale commented on Mar 30, 2022

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions and please check out this if you are wondering why we auto close issues.

  10. reynoldsalec commented on May 5, 2022

    @reynoldsalec
    SponsorMember

    ...and this is still totally an issue. Taking a look at this after some folks mentioned it on Slack.

  11. transferred this issue fromlando/landoon May 5, 2022
  12. reynoldsalec commented on May 23, 2022

    @reynoldsalec
    SponsorMember

    Ok, so in some ways the "root issue" here is one of documentation.

    The Lando Apache service accepts a .htaccess-lando file just fine, but virtually no one uses the standalone Lando Apache service. Typically Lando users are using a WordPress/Drupal recipe that leverages Lando's PHP service, and that service actually uses different Dockerfiles to generate the Apache server, which do not make the changes to httpd.conf necessary to read the .htaccess-lando file.

    That said, I think we've had enough consistent interest/confusion in this feature that it should be added to the PHP service.

    I'm moving this ticket to the lando/php project, steps for implementation are to...

    1. Create custom httpd.conf with the line AccessFileName .htaccess-lando .htaccess
    2. Make sure that custom config file is copied to the correct location via the Dockerfile (probably /etc/apache2/apache2.conf)
    3. Add tests to the PHP service, similar to the ones on the Apache service testing the custom .htaccess file
  13. transferred this issue fromlando/apacheon May 23, 2022
  14. changed the title [-].htaccess-lando not overriding .htaccess[/-] [+]Allow a .htaccess-lando to override .htaccess[/+] on May 23, 2022
  15. reynoldsalec commented on May 23, 2022

    @reynoldsalec
    SponsorMember

    ...also noting that when we re-do the PHP service, we should have it consume the Lando Apache service.

  16. yorkshire-pudding commented on Sep 1, 2022

    @yorkshire-pudding

    Thanks @anacolautti for documenting the workaround.
    It works a treat.

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

Metadata

Metadata

Assignees

Labels

apachebug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions