• Resolved Susan Hayse

    (@suhayse)


    I have my WP core files in a subdirectory with the index.php and htaccess files at the root directory. This is all working swell.

    My confusion is with www or no www htaccess stuff. I was given the advice that it was important to add the code below to my htaccess file at the root directory level. But now, my site stats in Google Analytics are garbled (some weeks showing zero visits where there were visits recorded before). So I know it’s looking at the wrong site – looking at mydomain.com without the www.

    Any hints about what I’ve done wrong? I know that the .htaccess file within the WP subdirectory doesn’t match the one at the root directory level. I didn’t add this www redirect code to that file. Could that be the problem?

    In addition, I was using W3 Total Cache plugin for a while and recently uninstalled it, removing the code it had inserted in my htaccess file.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # 301 redirect to domain to 'www.'
    RewriteCond %{HTTP_HOST} ^mydomain.com$ [NC]
    RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]
    </IfModule>
    # END WordPress
Viewing 8 replies - 1 through 8 (of 8 total)
  • # 301 redirect to domain to 'www.'
    RewriteCond %{HTTP_HOST} ^mydomain.com$ [NC]
    RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]

    Should be at the top of your .htaccess file.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Also, you don’t need that stuff. WordPress itself enforces the www or lack thereof according to its own URL settings.

    Otto, it doesn’t work too well with a network. When you type gangleri.nl/articles, you are redirected to https://www.gangleri.nl.

    Thread Starter Susan Hayse

    (@suhayse)

    So the 301 snippet can be outside the wordpress rewrite statement?

    I got the message at WordCamp that we needed to be using that redirect to avoid getting dinged for duplicate content. So this isn’t necessary at all now with WP 3?

    Moderator James Huff

    (@macmanx)

    So the 301 snippet can be outside the wordpress rewrite statement?

    That’s correct. In fact, anything between # BEGIN WordPress and # END WordPress will be replaced if you every re-generate your permalink structure, so it’s a good idea to regard those two lines as “keep out”.

    I got the message at WordCamp that we needed to be using that redirect to avoid getting dinged for duplicate content. So this isn’t necessary at all now with WP 3?

    That’s correct, WP should take of it for you. However, it doesn’t seem to work in Roy’s multisite network. I haven’t run WP as multisite network yet, so I can’t confirm this myself, but I trust Roy enough to take him at his word. If you aren’t running a multisite network, you should be fine.

    Thread Starter Susan Hayse

    (@suhayse)

    Well, I’m a plain old singleton site, so I think I’m going to ditch that snippet. Thank you all for your help!

    Moderator James Huff

    (@macmanx)

    You’re welcome!

    You’re welcome.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Totally confused about www or no www’ is closed to new replies.