htaccess non-www rewrite showing index.php in URL I am using htaccess to rewrite any www url to a non-www version

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]


When I type domain.com/about it works fine, however when I type www.domain.com/about it changes the URL to domain.com/index.php?p=about

I have 'omitScriptNameInUrls' =&gt; true, enabled.
I also have this in my .htaccess file

RewriteEngine On

# Send would-be 404 requests to Craft
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
RewriteRule (.+) index.php?p=$1 [QSA,L]


What am I doing wrong here?

Edit:
Here is the the vhost file.

&lt;VirtualHost *:80&gt;
    ServerName domain.com
    ServerAdmin webmaster@domain.com
    DocumentRoot /var/www/

    &lt;Directory /var/www/&gt;
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    &lt;/Directory&gt;

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
&lt;/VirtualHost&gt;
Check out the official Apache documentation on Canonical domain rewrites: https://httpd.apache.org/docs/2.4/rewrite/remapping.html#canonicalhost