How come I can't move the contents of my .htaccess file into my virtual host?

admin

Administrator
Staff member
I have an .htaccess file for my Wordpress website with this content.

Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

I moved this content into the Apache virtual host for my site (below) and deleted the htaccess file.

Code:
<VirtualHost *:80>
ServerName 68.183.153.223
DocumentRoot /home/david/wordpressWebSite

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

</VirtualHost>

However, when I attempt to restart Apache, Apache outputs an error.

Code:
RewriteBase: only valid in per-directory config files
Action 'restart' failed.

I thought that htaccess file contents could be moved to virtual hosts. What is awry?