In other words, I’ve seriously overcomplicated this setup but after about a half-day of hammering away at it it seems it can be done after all, and my faults were minor.
Important takeaways…
I have a standard apache server setup that serves files from /var/www/html. This is simply defined in my /etc/apache2/sites-enabled directory as a virtual host, like this:
<VirtualHost *:80>
ServerAdmin mog@mogness.net
DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I have a fully isolated wordpress environment someplace else on my filesystem that I use an alias to patch into the web server with it’s own configuration file. WordPress will write it’s own .htaccess file for you in it’s root, so remove one if you’ve made it, or rename it so you don’t get in the way! It should look something like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /alias
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . alias/index.php [L]
</IfModule>
# END WordPress
Most apache installs don’t have mod-rewrite enabled by default, so you ought to take care of that early on. Make sure you’ve got a link in your mods-enabled directory that looks something like this:
lrwxrwxrwx 1 root root 30 Aug 6 14:02 rewrite.load -> ../mods-available/rewrite.load
My over-engineering is the fact that I’ve got it now linked into my apache conf-enabled directory, with a conf file that looks like this:
# this should set up my dev box
Alias /solovic “/actual/path/to/my/aliased/webpath.com”
<Directory "/actual/path/to/my/aliased/webpath.com">
AllowOverride All
RewriteEngine On
RewriteBase "/actual/path/to/my/aliased/webpath.com"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ./alias/index.php [L]
#DirectoryIndex index.php
<IfModule mod_php.c>
<IfModule mod_mime.c>
AddType application/x-httpd-php .php
</IfModule>
<FilesMatch ".+\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_admin_flag allow_url_fopen On
php_value include_path .
</IfModule>
Require all granted
</Directory>
My major fuckup, and what wasted most of my day in this case, was the RewriteRule above in my directory path. I left out that alias bit and so, apache, very confused at why I would want to send everything back to /var/www/html/index.php, kept spitting me 404s. So, if you’ve got a setup like mine and are pulling out your hair, it’s probably related to mod_rewrite, so check your apache error logs. You may come across something like this:
script '/var/www/html/index.php' not found or unable to stat, referer: http://host/aliasdir/wp-admin/post.php?post=10575&action=edit
And that, as they say, is that.