Question redirects to www then to back non-www

Posted March 1, 2016 4.6k views

When I go to, my website instantaneously goes to (I can’t tell if there is a / at the end of the url, because it happens so fast) and then it goes back to

The website does not redirect when I simply go to (with the / at the end).

I followed redirect www to non-www digitalocean guide but it is frustrating that my website goes from non-www to www then back again only for this instance.

Can anyone offer any advice as to how to make my website not do this behavior?

Thank you

  • Just an update for clarity:

    current situation

    1. User enters
    2. automatically redirects to (or /folder/? can’t tell, it happens too quick)
    3. instantaneously redirects to

    desired situation

    1. User enters
    2. just goes to or
  • Also let me mention my website is

    please try to go to and watch it go to www and back to non-www. It’s really annoying. (with the slash at the end) works fine.

  • Hi Ken,

    What web server software are you using to host your site? What does the config for your site look like?

  • Hey Brook, I appreciate you helping me with this.
    I am running Apache. Can you point me to the config for the information that you need?

    For domain record settings, i have an entry of @ pointing to my server ip address and an entry of www pointing to my server ip address

    Here is what is in this file:
    sudo vi /etc/apache2/sites-enabled/kensch.conf

    <VirtualHost *:80>
    DocumentRoot /var/www/
    ErrorLog ${APACHELOGDIR}/error.log
    CustomLog ${APACHELOGDIR}/access.log combined

    <Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all

    Here is my ../www/ file

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www.(.)$ [NC]
    RewriteRule ^(.
    )$ http://%1/$1 [R=301,L]

  • My first blush is that it’s related to the rewrite regex - and that there’s a case with the trailing / being there or not that is causing this. I’ll investigate and get back to you.

  • Show 3 more comments

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer