Question

What would be the best way to redirect my non-www urls to www url in my site.

I think they are being redirected with a 301 redirect now but traffic that is being sent to my non-www is not tracked properly with google analytics. So I guess it's not configured properly.

Hope someone can help.

Thanks

Was it helpful?

Solution

A non-www to www can be done using Apache Rewrite Engine and htaccess file. Create a .htaccess file in your public html directory with following content..

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.youraddress.com$ [NC]
RewriteRule ^(.*)$ http://www.youraddress.com/$1 [R=301,L]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top