WordPress.org

Support

Support » Plugins and Hacks » BulletProof Security » [Resolved] non www 301 redirect

[Resolved] non www 301 redirect

Viewing 15 replies - 1 through 15 (of 19 total)
  • Plugin Author AITpro

    @aitpro

    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.

    Plugin Author AITpro

    @aitpro

    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]

    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]

    Plugin Author AITpro

    @aitpro

    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.

    Plugin Author AITpro

    @aitpro

    And I have to ask…

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

    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

    Plugin Author AITpro

    @aitpro

    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

    Confirmed.

    Plugin Author AITpro

    @aitpro

    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.

    Plugin Author AITpro

    @aitpro

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

    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!

    Plugin Author AITpro

    @aitpro

    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.

    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.

    Plugin Author AITpro

    @aitpro

    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

    Plugin Author AITpro

    @aitpro

    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
            )

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘[Resolved] non www 301 redirect’ is closed to new replies.
Skip to toolbar