I have an Apache virtual host configured for a website powered by Wordpress.
<VirtualHost *:80>
ServerName 67.178.132.253
DocumentRoot /home/david/wordpressWebsite
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteCond /home/david/wordpressWebsite%{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
</VirtualHost>
How can I avoid hard-coding /home/david/wordpressWebsite
twice? I don't want to use REQUEST_URI
since that involves an extra request.
Here's my attempt at using a directory context. I made a file in sites-available with these contents.
DocumentRoot /home/david/wordpressWebsite
<Directory /home/david/wordpressWebsite>
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
# You need these somewhere, anyway; better to not put them on the root.
Order allow,deny
Allow from all
</Directory>
For some reason, Apache is seeking files in /var/www as evinced in my error logs:
[error] [client 69.175.67.64] File does not exist: /var/www/about,
referer: http://67.178.132.253/