WordPress.org

Ready to get started?Download WordPress

Forums

BulletProof Security
[resolved] non www 301 redirect (20 posts)

  1. coastalwebdesign
    Member
    Posted 1 year ago #

    I have read a bunch of threads regarding non www to www 301 redirect but can't seem to get it to take. Can you explain exactly where the edit should be made and the most generic way of implementing this please?

    Thanks!

    http://wordpress.org/extend/plugins/bulletproof-security/

  2. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    First off go to your WordPress Settings >>> General page and make sure your WordPress Address (URL) & Site Address (URL) are what you want.

    Source: forum.ait-pro.com/forums/topic/htaccess-redirect-www-to-non-www-htaccess-redirect-non-www-to-www/#post-5566

    A Custom Code Video Tutorial link is on the Custom Code page.

    You can now add non-www to www custom htaccess code to BPS Custom Code as of BPS .48.6 in this Custom Code Text Area/Text box.
    CUSTOM CODE WP REWRITE LOOP START: Add www to non-www/non-www to www code here
    You MUST copy and paste the entire Timthumb section of code from your root .htaccess file into this text box first. You can then edit and modify the code in this text window and save your changes.

  3. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    oops just noticed the blue help text is wrong.
    Should say: You MUST copy and paste the entire WP REWRITE LOOP START section of code from your root .htaccess file into this text box first. You can then edit and modify the code in this text window and save your changes.

    This is the Rewrite Loop Start section of code

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]

    After you add your non-www to www code, save your custom code, click the AutoMagic buttons and activate BulletProof Modes then you will see something like this code in your root .htaccess file (and Custom Code). Click the Custom Code Video Tutorial link on the BPS Custom Code page for additional non-www to www help info.

    # CUSTOM CODE WP REWRITE LOOP START - Your Custom htaccess code will be created here with AutoMagic
    # WP REWRITE LOOP START
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
    RewriteRule ^index\.php$ - [L]
  4. coastalwebdesign
    Member
    Posted 1 year ago #

    Thanks for your help. Followed the directions, read, and reread them to be sure. Still not getting a redirect.

    # CUSTOM CODE WP REWRITE LOOP START - Your Custom htaccess code will be created here with AutoMagic
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
    RewriteRule ^index\.php$ - [L]

  5. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    Do you have a standard single site installation of WordPress or a Network/Multisite installation of WordPress?
    Do you have a root folder installation of WordPress or a subfolder installation of WordPress?
    Have you done all the Custom Code steps?

    Root htaccess File Custom Code Setup Steps
    1. Enter your custom code in the appropriate Custom Code text box.
    2. Click the Save Root Custom Code button to save your custom code.
    3. Go to the Security Modes page and click the AutoMagic buttons.
    4. Activate BulletProof Mode for your Root folder.

  6. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    And I have to ask...

    Are you adding your actual domain name in place of "domain.com"?

  7. coastalwebdesign
    Member
    Posted 1 year ago #

    Do you have a standard single site installation of WordPress or a Network/Multisite installation of WordPress? Yes (to my understanding)
    Do you have a root folder installation of WordPress or a subfolder installation of WordPress? Yes (to my understanding)
    Have you done all the Custom Code steps? Yes (to my understanding)

    Site: witnessthechange.com

  8. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    Do you have the correct WordPress General Settings below?

    Your WordPress Address (URL) is: http://www.witnessthechange.com
    Your Site Address (URL) is: http://www.witnessthechange.com
  9. coastalwebdesign
    Member
    Posted 1 year ago #

    Confirmed.

  10. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    hmm I just discovered that my main domain has some sort of an issue with WP Super Cache not rewriting my non-www to www URL. LOL

    Ends up rewriting to this, whatever this is?

    http://www.ait-pro.com/wp-content/cache/supercache/ait-pro.com/index.html.gz

    On all my other sites I do not have any non-www to rewriting htaccess code and the WordPress General Settings automatically rewrite non-www to www.

    When I look at the source code of your website I see that you have W3TC and Wordfence installed, which may be a factor here. Try clearing your W3TC cache and your Browser cache and see what happens. I am not sure if Wordfence could do something like this, but after clearing your cache try deactivating Wordfence next.

    What is odd is that you really do not need to use non-www to www rewriting .htaccess code since WordPress itself should already be doing this for your site.

  11. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    The problem on my main site was corrupt cache. After deleting the corrupt cache files the non-www to www rewrite works fine.

  12. coastalwebdesign
    Member
    Posted 1 year ago #

    LOL

    Well, I deactivated Wordfence and W3TC and cleared browser cache and still no luck. I have tried multiple browsers as well.

    I have also heard that you should not need a redirect but I guess that just confused me more.

    Bizarre!

  13. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    You actually need to clear your W3TC cache not just deactivate the W3TC plugin.

    If you are just generally trying to do the non-www to www redirect then this is already done based on your WP Settings.

    Let's say you had non-www WP settings for a while set in your WP Settings and you have a whole bunch of posts and pages indexed by Google that do not have the www prefix. In order to make sure those links get redirected correctly without generating 404 errors you would then use the non-www to www htaccess code. After about a month max Google should have all your post and page links/URLs indexed with www, but once again WordPress should already be handling this redirect correctly.

    The only other things I can think to do would be to deactivate all or your plugins and switch your Theme to see if this is a plugin or theme issue.

  14. coastalwebdesign
    Member
    Posted 1 year ago #

    Ok I will look into that.

    So the fact that my site is accessible via domain.com and http://www.domain.com does not hurt SEO capabilities? That was the primary purpose behind this task.

    Thanks for all your time. I will update to resolved.

  15. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    Yep, this is not a real big deal and will not affect SEO in any way. What is important is that when I check your site using this Google site search for indexed posts and pages below it shows that your posts and pages are being indexed with the www prefix, which means that the Sitemap xml file that was submitted to Google from your website has the www prefix in URL's.

    site:witnessthechange.com

  16. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    Also I checked the DNS info for your site and everything looks good.

    [3] => Array
            (
                [host] => www.witnessthechange.com
                [type] => CNAME
                [target] => witnessthechange.com
                [class] => IN
                [ttl] => 3600
            )
  17. coastalwebdesign
    Member
    Posted 1 year ago #

    Excellent. Your valuable time is much, much appreciated!

  18. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    Looks like this issue might be related to W3TC afterall. This is a very old Thread, but logically it could still be the source of the issue/problem.

    http://wordpress.org/support/topic/plugin-w3-total-cache-non-www-redirect-fails-with-w3tc-activated?replies=21

    You can copy the W3TC htaccess code and add it after the custom code you added already. I don't think this will break anything else.

    # CUSTOM CODE WP REWRITE LOOP START - Your Custom htaccess code will be created here with AutoMagic
    # WP REWRITE LOOP START
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
    RewriteRule ^index\.php$ - [L]
    
    W3TC htaccess code goes here
  19. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    or maybe this would be better to do if you have W3TC installed.

    http://wordpress.org/support/topic/plugin-w3-total-cache-non-www-to-www-redirects-not-working?replies=3

    Instead of adding your non-www to www code to the WP REWRITE LOOP code create this code instead separately and add it to the CUSTOM CODE TOP PHP/PHP.INI HANDLER/CACHE CODE: Add php.ini handler and/or plugin cache code here text box. This will prevent possible problems with deeper level URL rewriting within the WP Rewrite Loop.

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
  20. Frederick Townes
    Member
    Posted 1 year ago #

    Will look into adding default code for this. Meanwhile what @AitPro writes here http://wordpress.org/support/topic/non-www-301-redirect?replies=18#post-4282903 should work in meanwhile.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags