My apache server is to establish having a very fundamental configuration. I did previously serve only one website from apache, let us refer to it as example.com. Inside the httpd.conf file, I'd some code to pressure the web site to continually show www within the url.

I lately added a subdomain for that site, blog.example.com. To be able to do that I desired to produce 2 virtual directory directives inside my httpd.conf file.

NameVirtualHost *:80
<VirtualHost *:80>
 ServerName example.com
 DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:80>
 ServerName blog.example.com
 DocumentRoot /var/www/blog
</VirtualHost>

Soon after this, I stored my rewrite code:

RewriteEngine On
RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://www.example.com/$1 [L,R]

However , this after adding the Virtual Directory code, the rewrite code is no more working. I attempted creating the next Directory directive, which does not appear to work on all.

<Directory "/var/www/html">
 Options Indexes MultiViews FollowSymLinks
 Order Deny,Allow
 Allow from all
 AllowOverride All
</Directory>

Furthermore, I attempted developing a .htaccess file within the html folder from the website and restarting apache, but nothing which i place in there's getting observed whatsoever.

Any assistance is greatly appreciated. Thanks!

Answer from comment by original poster:

Ok, I believed it. I simply required to slowly move the rewrite logic inside the start and finish Directives. Just help @animuson. – Henry Wrinkler