• Hi,

    According to pingdom tools the 301 redirect from the non www to www version of our site takes 4 seconds to load and the redirect from http to https takes another 3 seconds.

    After reading many threads I have a few questions:

    1) For the non www redirect I simply added https://www.mydomain.com in the WP Settings > General page. In some articles it is mentioned that this is enough but I read many people are also editing the htaccess with the following code. What is the difference if any and which one is better?

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

    2) I am forcing https using cloudflare page rules. Would using a 301 redirect in htaccess speed the site? (not sure if this is something that can be done at all)

    Thanks in advance!

Viewing 4 replies - 1 through 4 (of 4 total)
  • For the non www redirect I simply added https://www.mydomain.com in the WP Settings > General page.

    That only tells WordPress what to expect and send back out. Here is how to be certain the search engines ever find only one site:

    RewriteEngine On
    RewriteBase /
    # add/change non-www. to www.
    RewriteCond %{HTTP_HOST} ^mydomain\.comt$ [NC]
    RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]
    RewriteRule ^index\.php$ - [L]

    Thread Starter WPNewbie9090

    (@wpnewbie9090)

    Thanks leejosepho

    Is this for search engines only (ie would this have any effect on load page if a user types mydomain.com on the browser) I already specified the preferred domain version on webmaster tools so the main search engines are already showing the www version

    Also, should the code be added at the top of the htaccess file before # BEGIN W3TC Browser Cache and # BEGIN WordPress or inside the section:

    # 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]
    </IfModule>
    
    # END WordPress

    Is this for search engines only (ie would this have any effect on load page if a user types mydomain.com on the browser) I already specified the preferred domain version on webmaster tools so the main search engines are already showing the www version

    I do not know as to any effect upon speed, but I do know WebMaster Tools would not have any effect upon the matter of a www and a non-www being seen as two different links to what would be seen as duplicate content.

    Also, should the code be added…

    After changing ‘mydomain\.com’ and ‘mydomain.com’ to your own, I believe this would be best:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    # add/change non-www. to www.
    RewriteCond %{HTTP_HOST} ^mydomain\.comt$ [NC]
    RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]
    # continue WordPress
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    Thread Starter WPNewbie9090

    (@wpnewbie9090)

    Got it thanks so much! Really appreciate your help ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘301 redirect from non www to www’ is closed to new replies.