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 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, To be able to do that I desired to produce 2 virtual directory directives inside my httpd.conf file.

NameVirtualHost *:80
<VirtualHost *:80>
 DocumentRoot /var/www/html
<VirtualHost *:80>
 DocumentRoot /var/www/blog

Soon after this, I stored my rewrite code:

RewriteEngine On
RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)$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

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