If you've a website running on apache web server that doesn't seem to redirect from non-www to www. This snippet will help you fix it quickly.

When this usually happens, there are plenty of options to try. From adding a www CNAME to domain records point towards main domain, add a 301 permanent redirect in the apache configuration, redirecting within the code. But the solution below is quicker and works all the time.

<VirtualHost *:80>
    ServerName devpeel.com
    Redirect permanent / http://www.devpeel.com/
</VirtualHost>

<VirtualHost *:80>
    ServerName www.devpeel.com
    # real server configuration
</VirtualHost>

Let us know in the comments section below if this works out for you.

You may also Like