Bedrock + Sage - wp = Wrong path for assets

Hi guys,

I’m currently using bedrock + sage starter theme and my bedrock setup goes without a subfolder, like this:

.env file

WP_HOME=http://combo.localhost
WP_SITEURL=http://combo.localhost

vhost

  DocumentRoot ~/bedrock/web/wp/
  <Directory ~/bedrock/web/wp/>

The thing is, my assets are in /app/themes/sage/assets/ which is a folder before /wp/ which I don’t want to show. Is there a way to make this work?

Thanks in advance

  DocumentRoot ~/bedrock/web/
  <Directory ~/bedrock/web/>

And me thinking that would make /wp/ folder explicit in url. That solved it correctly. Thanks @austin :sweat_smile:

EDIT: That actually breaks wp-admin unfortunatelly. Any other idea @austin? I just want to not show /wp/ in my url. My production server has nginx and locally is apache. Both gives the same error.

Access it via /wp/wp-admin

Here is a working nginx config to put in your sites-enabled

server {
  set $site_name example.dev;

  listen *:80;
  server_name  example.dev;
  access_log   /srv/www/example.dev/logs/example.dev.access.log;
  error_log    /srv/www/example.dev/logs/example.dev.error.log;

  root  /srv/www/example.dev/current/web;
  index index.php;

  charset utf-8;
  
  include wordpress.conf;
}

server {
  listen *:80;
  server_name www.example.dev;
  return 301 $scheme://example.dev$request_uri;
}

and wordpress.conf:

location / {
  try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
  try_files $uri =404;
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_pass unix:/var/run/php5-fpm-$site_name.sock;
  client_max_body_size 0;
}

This is assuming you are using a https://github.com/roots/bedrock-ansible style PHP setup

Say this out loud to yourself a couple times and perhaps you will become aware of the trouble this can cause :stuck_out_tongue:. Don’t do this.

Also here is my .env file:

WP_SITEURL='http://example.dev/wp'
WP_HOME='http://example.dev'

I know it’s not ideal, but working in OSX with nginx seems a lot of trouble too. The better way here would be VMing the whole thing (Vagrant, I’m going to try soon) but since I don’t have this choice right now, this is what I can do.

I know I won’t be using any .htaccess stuff for now. This nginx setup is what I’m using, almost exactly.

Having said that, folder /wp/wp-admin gives me 404. You can see it live at http://beta.combomultinet.com (the difference here is that .env is, of course, http://beta.combomultinet.com in both wp_home and wp_siteurl). Like I said, nginx setup is almost identical (with some extras about 404).

EDIT: I’m sorry @austin, your answer came after I sent this reply. Your setup works for nginx successfully. Is there any case in apache? I’ll try 30min of this, if not I’m gonna brew install nginx here too.

Definitely recommend using bedrock-ansible for local dev. It’s incredibly easy. Way easier than messing with OSX. Those configs I posted come from it anyway.

I’ve just installed nginx here, just for my sanity. It’s working, but I’m going to check ansible too. The idea of running a VM on top of so much optimization seems so wrong but hell, the sanity of same environments pays it off.