• Resolved John

    (@dsl225)


    Is it safe to delete the “www” in settings for an existing site that already has SSL enabled with .htaccess 301 redirection active?

    I’m getting a “Avoid landing page redirects” at pagespeed tests and want to check whether the issue is related.

    Thanks.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Mark

    (@markwolters)

    Hi,

    you can update both the WordPress and site address to non-www. You’d have to update both, if you are unsure how to approach this exactly I would recommend against it as it can have some side effects. For more information about avoiding landing page redirects see https://really-simple-ssl.com/knowledge-base/avoid-landing-page-redirects/

    Mark

    Thread Starter John

    (@dsl225)

    Many thanks for your swift reply, well noted.

    Thread Starter John

    (@dsl225)

    Unfortunately this snippet doesn’t seem to work here:

    #redirect all www requests to non-www.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
    </IfModule>

    as the site becomes unavailable and I only get the cached files.

    Plugin Author Mark

    (@markwolters)

    Hi John,

    have you enabled the Really Simple SSL htaccess redirect in the Settings->SSL->Settings menu? The .htaccess redirect needs to be active before the snippet can work.

    Mark

    Thread Starter John

    (@dsl225)

    Yes this was already enabled and I just added the new snippet above it.
    The final was like that in .htaccess:

    #redirect all www requests to non-www.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
    </IfModule>
    
    # BEGIN rlrssslReallySimpleSSL rsssl_version[3.3.5]
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTPS} !=on [NC]
    RewriteCond %{REQUEST_URI} !wp-content\/cache\/(all|wpfc-mobile-cache)
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
    </IfModule>
    # END rlrssslReallySimpleSSL
    Plugin Author Mark

    (@markwolters)

    The redirect will only be done if Apache module mod_rewrite.c is enabled in the webserver configuration. Could you check with your hosting provider if this module has been enabled?

    Mark

    Thread Starter John

    (@dsl225)

    Thanks Mark, will check with them and get back here.

    Thread Starter John

    (@dsl225)

    The host support replied that:

    The mod_rewrite.c is already enabled in the server.

    Any further clues?
    May I send you the URL?

    Plugin Author Mark

    (@markwolters)

    Strange, the redirect should work when mod_rewrite.c has been enabled. You could try to move the redirect to the top of your .htaccess file to see if that makes a difference. You could also try to make the redirect redirect explicitly to yourdomain.com, like this:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\. [NC]
    RewriteRule ^(.*)$ https://yourdomain.com/$1 [L,R=301]
    </IfModule>
    Thread Starter John

    (@dsl225)

    Thanks for this.
    Tried both and still none worked.
    There must be something else that blocks but can’t find what.

    PS: I just found another occurrence of mod_rewrite.c by WP Fastest Cache:

    # BEGIN WpFastestCache
    # Modified Time: 08-09-20 19:09:38
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTPS} =on
    RewriteCond %{HTTP_HOST} ^www.mysite.com

    Is there any conflict in there?

    Plugin Author Mark

    (@markwolters)

    there won’t be a conflict if multiple rules use the <IfModule mod_rewrite.c> line. I suspect that either something is going wrong on the server level which prevents the redirect from working correctly, or that there’s another redirect forcing the redirect to www. You could check the rest of your .htaccess file, wp-config.php file or your theme’s functions.php for this.

    Mark

    Thread Starter John

    (@dsl225)

    Many thanks for your feedback, will check further.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Removing “www” from existing URL’ is closed to new replies.