How To Redirect www to non-www OR non-www to www with Apache

1. Configure DNS Records In order to set up the desired redirect, to or vice versa, you must have an A record for each name. 2. Enable the mod_rewrite module 3.1 Update site.conf or .htaccess file ( www to non-www) 3.2 Update site.conf or .htaccess file ( non-www to www) Example ServerName Documentroot /var/www/html/ RewriteEngine on RewriteCond %{HTTP_HOST} ^ RewriteRule (.*)$1 [R=301,L] </VirtualHost>

August 31, 2019 · 1 min · 67 words · Akhil Jalagam