Symlink for all in one security and firewall plugin

I’m using the All In One WP Security & Firewall which is expecting the .htaccess to be located at example.com/wp/.htaccess.

Since my .htaccess is located at example.com/.htaccess, I’ve created a symlink in /shared/web/.htaccess to /shared/web/wp/.htaccess so I can use a single .htaccess file because two files is not as good as one.

I have this line in my deploy.rb:

# Linked files
set :linked_files, %w{.env web/.htaccess web/wp/.htaccess}

When my deploy runs, I see the symlinks being built:

- Running /usr/bin/env ln -s /var/www/html/example/shared/web/.htaccess /var/www/html/example/releases/20150314173824/web/.htaccess
- Running /usr/bin/env ln -s /var/www/html/example/shared/web/wp/.htaccess /var/www/html/example/releases/20150314173824/web/wp/.htaccess

So far, so good.

Almost.

The first one works great in the release, but the second one doesn’t show up. What am I doing wrong?

As a follow up to a potential troubleshooting question, if I create two, separate .htaccess files, one in /shared/web and one in /shared/web/wp, the deploys work and the symlinks work properly.

But then I still have two different files, so, you know, not as good…

My guess: composer install gets run after the symlinking which overwrite the wp directory since Composer manages it.

You guessed correctly! Any suggestions on my next steps? I guess I’d have to write another, like, command after composer gets run? Is that at least going in the right direction?

You can commit symlinks into your Git repo so I’d try that.

As a side not that plugin isn’t coded very well since it makes bad assumptions about file paths.

Themes/plugins should never be referenced from ABSPATH :frowning:

I’m also looking at some other plugins that also are expecting .htaccess to be at example.com/wp.

What is the preferred way for roots/bedrock to handle this?

We can’t be of much help here I’m afraid. We use Nginx anyway but I’d try and find a plugin that at least lets you override their default .htaccess location. They really shouldn’t be hardcoding some path without the option to change it.