Wordpress .htaccess www redirect fail












0















I've just been asked to help administer a charities WordPress site. It's using http and I'd like to modify the .htaccess redirect to www. The .htaccess file looks bog standard, with the addition of a 404 at the start:



ErrorDocument 404 /error.php
# 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


I've tried a couple of times to add the www redirect code but it keeps failing every time:



ErrorDocument 404 /error.php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^l-a-m.org [NC]
RewriteRule ^(.*)$ http://www.l-a-m.org/$1 [L,R=301]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress


I've also tried moving the redirect block out of the # WordPress code and putting it at the start of the file, but this doesn't work either.



I'm a complete newbie to WordPress so can anyone help and tell me where I'm going wrong please?










share|improve this question





























    0















    I've just been asked to help administer a charities WordPress site. It's using http and I'd like to modify the .htaccess redirect to www. The .htaccess file looks bog standard, with the addition of a 404 at the start:



    ErrorDocument 404 /error.php
    # 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


    I've tried a couple of times to add the www redirect code but it keeps failing every time:



    ErrorDocument 404 /error.php
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^l-a-m.org [NC]
    RewriteRule ^(.*)$ http://www.l-a-m.org/$1 [L,R=301]
    RewriteBase /
    RewriteRule ^index.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress


    I've also tried moving the redirect block out of the # WordPress code and putting it at the start of the file, but this doesn't work either.



    I'm a complete newbie to WordPress so can anyone help and tell me where I'm going wrong please?










    share|improve this question



























      0












      0








      0








      I've just been asked to help administer a charities WordPress site. It's using http and I'd like to modify the .htaccess redirect to www. The .htaccess file looks bog standard, with the addition of a 404 at the start:



      ErrorDocument 404 /error.php
      # 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


      I've tried a couple of times to add the www redirect code but it keeps failing every time:



      ErrorDocument 404 /error.php
      # BEGIN WordPress
      <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteCond %{HTTP_HOST} ^l-a-m.org [NC]
      RewriteRule ^(.*)$ http://www.l-a-m.org/$1 [L,R=301]
      RewriteBase /
      RewriteRule ^index.php$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]
      </IfModule>
      # END WordPress


      I've also tried moving the redirect block out of the # WordPress code and putting it at the start of the file, but this doesn't work either.



      I'm a complete newbie to WordPress so can anyone help and tell me where I'm going wrong please?










      share|improve this question
















      I've just been asked to help administer a charities WordPress site. It's using http and I'd like to modify the .htaccess redirect to www. The .htaccess file looks bog standard, with the addition of a 404 at the start:



      ErrorDocument 404 /error.php
      # 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


      I've tried a couple of times to add the www redirect code but it keeps failing every time:



      ErrorDocument 404 /error.php
      # BEGIN WordPress
      <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteCond %{HTTP_HOST} ^l-a-m.org [NC]
      RewriteRule ^(.*)$ http://www.l-a-m.org/$1 [L,R=301]
      RewriteBase /
      RewriteRule ^index.php$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]
      </IfModule>
      # END WordPress


      I've also tried moving the redirect block out of the # WordPress code and putting it at the start of the file, but this doesn't work either.



      I'm a complete newbie to WordPress so can anyone help and tell me where I'm going wrong please?







      php wordpress .htaccess url-redirection






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 27 '18 at 12:08







      mark clarke

















      asked Nov 27 '18 at 12:02









      mark clarkemark clarke

      133




      133
























          3 Answers
          3






          active

          oldest

          votes


















          0














          You can try :



          RewriteCond %{HTTP_HOST} ^example.com$
          RewriteRule ^(.*) http://www.example.com/$1 [QSA,L,R=301]


          or to force https :



          RewriteCond %{HTTP_HOST} ^example.com$
          RewriteCond %{HTTPS} off
          RewriteRule ^(.*) https://www.example.com/$1 [QSA,L,R=301]


          Replace example.com by the host you want.



          EDIT IMPORTANT :



          In WordPress, don't use .htaccess, use wp-config.php and adapt the 2 lines with the right host name :



          define('WP_HOME','http://www.domainname.com');
          define('WP_SITEURL','http://www.domainname.com');





          share|improve this answer


























          • Thanks Shim-Sao, whenever I replace RewriteCond %{HTTP_HOST} ^example.com$ with the url RewriteCond %{HTTP_HOST} ^l-a-m.org$ it fails with the site being unreachable. The only code which works is when I replace ^l-a-m.org$ with ^l-a-m.org$ ... however, the site stays up but the redirect to www doesn't work.

            – mark clarke
            Nov 27 '18 at 14:00











          • I added "http://" in front of l-a-m.org but stackoverflow displayed this as a url

            – mark clarke
            Nov 27 '18 at 14:02











          • Ok. I use it for Joomla and it work well but in fact you should force www in WordPress using wp-config.php, no need to make changes in .htaccess. Explanation here : itsupportguides.com/knowledge-base/wordpress/…

            – Shim-Sao
            Nov 27 '18 at 14:25








          • 1





            Thanks Shim-Sao. I updated the wp-config.php and added the following lines which worked! define('WP_HOME','l-a-m.org'); define('WP_SITEURL','l-a-m.org');

            – mark clarke
            Nov 27 '18 at 14:28













          • I'm pleased to help you :) I will edit my post.

            – Shim-Sao
            Nov 27 '18 at 14:31



















          1














          Answer by Shim-Sao in his comments ... modifying the .htaccess file didn't work, so I edited the wp-config.php and added the following lines which worked:



          define('WP_HOME','http://www.l-a-m.org');
          define('WP_SITEURL','http://www.l-a-m.org');

          /* That's all, stop editing! Happy blogging. */





          share|improve this answer































            0














            Try replacing:



            RewriteCond %{HTTP_HOST} ^l-a-m.org [NC]
            RewriteRule ^(.*)$ http://www.l-a-m.org/$1 [L,R=301]


            with:



            RewriteCond %{HTTP_HOST} !^www. [NC]
            RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


            You also mentioned previous attempts "keep failing". Could you tell us what is going wrong, since it may be something that will also cause the approach above to fail.






            share|improve this answer
























            • Thanks JakeSteam, I've tried your code block but it takes the site down with the error message "too many redirects".

              – mark clarke
              Nov 27 '18 at 13:55













            • @markclarke If my answer helped, please feel free to upvote / mark it as the answer!

              – JakeSteam
              Nov 27 '18 at 13:57











            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53499265%2fwordpress-htaccess-www-redirect-fail%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You can try :



            RewriteCond %{HTTP_HOST} ^example.com$
            RewriteRule ^(.*) http://www.example.com/$1 [QSA,L,R=301]


            or to force https :



            RewriteCond %{HTTP_HOST} ^example.com$
            RewriteCond %{HTTPS} off
            RewriteRule ^(.*) https://www.example.com/$1 [QSA,L,R=301]


            Replace example.com by the host you want.



            EDIT IMPORTANT :



            In WordPress, don't use .htaccess, use wp-config.php and adapt the 2 lines with the right host name :



            define('WP_HOME','http://www.domainname.com');
            define('WP_SITEURL','http://www.domainname.com');





            share|improve this answer


























            • Thanks Shim-Sao, whenever I replace RewriteCond %{HTTP_HOST} ^example.com$ with the url RewriteCond %{HTTP_HOST} ^l-a-m.org$ it fails with the site being unreachable. The only code which works is when I replace ^l-a-m.org$ with ^l-a-m.org$ ... however, the site stays up but the redirect to www doesn't work.

              – mark clarke
              Nov 27 '18 at 14:00











            • I added "http://" in front of l-a-m.org but stackoverflow displayed this as a url

              – mark clarke
              Nov 27 '18 at 14:02











            • Ok. I use it for Joomla and it work well but in fact you should force www in WordPress using wp-config.php, no need to make changes in .htaccess. Explanation here : itsupportguides.com/knowledge-base/wordpress/…

              – Shim-Sao
              Nov 27 '18 at 14:25








            • 1





              Thanks Shim-Sao. I updated the wp-config.php and added the following lines which worked! define('WP_HOME','l-a-m.org'); define('WP_SITEURL','l-a-m.org');

              – mark clarke
              Nov 27 '18 at 14:28













            • I'm pleased to help you :) I will edit my post.

              – Shim-Sao
              Nov 27 '18 at 14:31
















            0














            You can try :



            RewriteCond %{HTTP_HOST} ^example.com$
            RewriteRule ^(.*) http://www.example.com/$1 [QSA,L,R=301]


            or to force https :



            RewriteCond %{HTTP_HOST} ^example.com$
            RewriteCond %{HTTPS} off
            RewriteRule ^(.*) https://www.example.com/$1 [QSA,L,R=301]


            Replace example.com by the host you want.



            EDIT IMPORTANT :



            In WordPress, don't use .htaccess, use wp-config.php and adapt the 2 lines with the right host name :



            define('WP_HOME','http://www.domainname.com');
            define('WP_SITEURL','http://www.domainname.com');





            share|improve this answer


























            • Thanks Shim-Sao, whenever I replace RewriteCond %{HTTP_HOST} ^example.com$ with the url RewriteCond %{HTTP_HOST} ^l-a-m.org$ it fails with the site being unreachable. The only code which works is when I replace ^l-a-m.org$ with ^l-a-m.org$ ... however, the site stays up but the redirect to www doesn't work.

              – mark clarke
              Nov 27 '18 at 14:00











            • I added "http://" in front of l-a-m.org but stackoverflow displayed this as a url

              – mark clarke
              Nov 27 '18 at 14:02











            • Ok. I use it for Joomla and it work well but in fact you should force www in WordPress using wp-config.php, no need to make changes in .htaccess. Explanation here : itsupportguides.com/knowledge-base/wordpress/…

              – Shim-Sao
              Nov 27 '18 at 14:25








            • 1





              Thanks Shim-Sao. I updated the wp-config.php and added the following lines which worked! define('WP_HOME','l-a-m.org'); define('WP_SITEURL','l-a-m.org');

              – mark clarke
              Nov 27 '18 at 14:28













            • I'm pleased to help you :) I will edit my post.

              – Shim-Sao
              Nov 27 '18 at 14:31














            0












            0








            0







            You can try :



            RewriteCond %{HTTP_HOST} ^example.com$
            RewriteRule ^(.*) http://www.example.com/$1 [QSA,L,R=301]


            or to force https :



            RewriteCond %{HTTP_HOST} ^example.com$
            RewriteCond %{HTTPS} off
            RewriteRule ^(.*) https://www.example.com/$1 [QSA,L,R=301]


            Replace example.com by the host you want.



            EDIT IMPORTANT :



            In WordPress, don't use .htaccess, use wp-config.php and adapt the 2 lines with the right host name :



            define('WP_HOME','http://www.domainname.com');
            define('WP_SITEURL','http://www.domainname.com');





            share|improve this answer















            You can try :



            RewriteCond %{HTTP_HOST} ^example.com$
            RewriteRule ^(.*) http://www.example.com/$1 [QSA,L,R=301]


            or to force https :



            RewriteCond %{HTTP_HOST} ^example.com$
            RewriteCond %{HTTPS} off
            RewriteRule ^(.*) https://www.example.com/$1 [QSA,L,R=301]


            Replace example.com by the host you want.



            EDIT IMPORTANT :



            In WordPress, don't use .htaccess, use wp-config.php and adapt the 2 lines with the right host name :



            define('WP_HOME','http://www.domainname.com');
            define('WP_SITEURL','http://www.domainname.com');






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 27 '18 at 14:35

























            answered Nov 27 '18 at 12:18









            Shim-SaoShim-Sao

            60938




            60938













            • Thanks Shim-Sao, whenever I replace RewriteCond %{HTTP_HOST} ^example.com$ with the url RewriteCond %{HTTP_HOST} ^l-a-m.org$ it fails with the site being unreachable. The only code which works is when I replace ^l-a-m.org$ with ^l-a-m.org$ ... however, the site stays up but the redirect to www doesn't work.

              – mark clarke
              Nov 27 '18 at 14:00











            • I added "http://" in front of l-a-m.org but stackoverflow displayed this as a url

              – mark clarke
              Nov 27 '18 at 14:02











            • Ok. I use it for Joomla and it work well but in fact you should force www in WordPress using wp-config.php, no need to make changes in .htaccess. Explanation here : itsupportguides.com/knowledge-base/wordpress/…

              – Shim-Sao
              Nov 27 '18 at 14:25








            • 1





              Thanks Shim-Sao. I updated the wp-config.php and added the following lines which worked! define('WP_HOME','l-a-m.org'); define('WP_SITEURL','l-a-m.org');

              – mark clarke
              Nov 27 '18 at 14:28













            • I'm pleased to help you :) I will edit my post.

              – Shim-Sao
              Nov 27 '18 at 14:31



















            • Thanks Shim-Sao, whenever I replace RewriteCond %{HTTP_HOST} ^example.com$ with the url RewriteCond %{HTTP_HOST} ^l-a-m.org$ it fails with the site being unreachable. The only code which works is when I replace ^l-a-m.org$ with ^l-a-m.org$ ... however, the site stays up but the redirect to www doesn't work.

              – mark clarke
              Nov 27 '18 at 14:00











            • I added "http://" in front of l-a-m.org but stackoverflow displayed this as a url

              – mark clarke
              Nov 27 '18 at 14:02











            • Ok. I use it for Joomla and it work well but in fact you should force www in WordPress using wp-config.php, no need to make changes in .htaccess. Explanation here : itsupportguides.com/knowledge-base/wordpress/…

              – Shim-Sao
              Nov 27 '18 at 14:25








            • 1





              Thanks Shim-Sao. I updated the wp-config.php and added the following lines which worked! define('WP_HOME','l-a-m.org'); define('WP_SITEURL','l-a-m.org');

              – mark clarke
              Nov 27 '18 at 14:28













            • I'm pleased to help you :) I will edit my post.

              – Shim-Sao
              Nov 27 '18 at 14:31

















            Thanks Shim-Sao, whenever I replace RewriteCond %{HTTP_HOST} ^example.com$ with the url RewriteCond %{HTTP_HOST} ^l-a-m.org$ it fails with the site being unreachable. The only code which works is when I replace ^l-a-m.org$ with ^l-a-m.org$ ... however, the site stays up but the redirect to www doesn't work.

            – mark clarke
            Nov 27 '18 at 14:00





            Thanks Shim-Sao, whenever I replace RewriteCond %{HTTP_HOST} ^example.com$ with the url RewriteCond %{HTTP_HOST} ^l-a-m.org$ it fails with the site being unreachable. The only code which works is when I replace ^l-a-m.org$ with ^l-a-m.org$ ... however, the site stays up but the redirect to www doesn't work.

            – mark clarke
            Nov 27 '18 at 14:00













            I added "http://" in front of l-a-m.org but stackoverflow displayed this as a url

            – mark clarke
            Nov 27 '18 at 14:02





            I added "http://" in front of l-a-m.org but stackoverflow displayed this as a url

            – mark clarke
            Nov 27 '18 at 14:02













            Ok. I use it for Joomla and it work well but in fact you should force www in WordPress using wp-config.php, no need to make changes in .htaccess. Explanation here : itsupportguides.com/knowledge-base/wordpress/…

            – Shim-Sao
            Nov 27 '18 at 14:25







            Ok. I use it for Joomla and it work well but in fact you should force www in WordPress using wp-config.php, no need to make changes in .htaccess. Explanation here : itsupportguides.com/knowledge-base/wordpress/…

            – Shim-Sao
            Nov 27 '18 at 14:25






            1




            1





            Thanks Shim-Sao. I updated the wp-config.php and added the following lines which worked! define('WP_HOME','l-a-m.org'); define('WP_SITEURL','l-a-m.org');

            – mark clarke
            Nov 27 '18 at 14:28







            Thanks Shim-Sao. I updated the wp-config.php and added the following lines which worked! define('WP_HOME','l-a-m.org'); define('WP_SITEURL','l-a-m.org');

            – mark clarke
            Nov 27 '18 at 14:28















            I'm pleased to help you :) I will edit my post.

            – Shim-Sao
            Nov 27 '18 at 14:31





            I'm pleased to help you :) I will edit my post.

            – Shim-Sao
            Nov 27 '18 at 14:31













            1














            Answer by Shim-Sao in his comments ... modifying the .htaccess file didn't work, so I edited the wp-config.php and added the following lines which worked:



            define('WP_HOME','http://www.l-a-m.org');
            define('WP_SITEURL','http://www.l-a-m.org');

            /* That's all, stop editing! Happy blogging. */





            share|improve this answer




























              1














              Answer by Shim-Sao in his comments ... modifying the .htaccess file didn't work, so I edited the wp-config.php and added the following lines which worked:



              define('WP_HOME','http://www.l-a-m.org');
              define('WP_SITEURL','http://www.l-a-m.org');

              /* That's all, stop editing! Happy blogging. */





              share|improve this answer


























                1












                1








                1







                Answer by Shim-Sao in his comments ... modifying the .htaccess file didn't work, so I edited the wp-config.php and added the following lines which worked:



                define('WP_HOME','http://www.l-a-m.org');
                define('WP_SITEURL','http://www.l-a-m.org');

                /* That's all, stop editing! Happy blogging. */





                share|improve this answer













                Answer by Shim-Sao in his comments ... modifying the .htaccess file didn't work, so I edited the wp-config.php and added the following lines which worked:



                define('WP_HOME','http://www.l-a-m.org');
                define('WP_SITEURL','http://www.l-a-m.org');

                /* That's all, stop editing! Happy blogging. */






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 27 '18 at 14:31









                mark clarkemark clarke

                133




                133























                    0














                    Try replacing:



                    RewriteCond %{HTTP_HOST} ^l-a-m.org [NC]
                    RewriteRule ^(.*)$ http://www.l-a-m.org/$1 [L,R=301]


                    with:



                    RewriteCond %{HTTP_HOST} !^www. [NC]
                    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


                    You also mentioned previous attempts "keep failing". Could you tell us what is going wrong, since it may be something that will also cause the approach above to fail.






                    share|improve this answer
























                    • Thanks JakeSteam, I've tried your code block but it takes the site down with the error message "too many redirects".

                      – mark clarke
                      Nov 27 '18 at 13:55













                    • @markclarke If my answer helped, please feel free to upvote / mark it as the answer!

                      – JakeSteam
                      Nov 27 '18 at 13:57
















                    0














                    Try replacing:



                    RewriteCond %{HTTP_HOST} ^l-a-m.org [NC]
                    RewriteRule ^(.*)$ http://www.l-a-m.org/$1 [L,R=301]


                    with:



                    RewriteCond %{HTTP_HOST} !^www. [NC]
                    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


                    You also mentioned previous attempts "keep failing". Could you tell us what is going wrong, since it may be something that will also cause the approach above to fail.






                    share|improve this answer
























                    • Thanks JakeSteam, I've tried your code block but it takes the site down with the error message "too many redirects".

                      – mark clarke
                      Nov 27 '18 at 13:55













                    • @markclarke If my answer helped, please feel free to upvote / mark it as the answer!

                      – JakeSteam
                      Nov 27 '18 at 13:57














                    0












                    0








                    0







                    Try replacing:



                    RewriteCond %{HTTP_HOST} ^l-a-m.org [NC]
                    RewriteRule ^(.*)$ http://www.l-a-m.org/$1 [L,R=301]


                    with:



                    RewriteCond %{HTTP_HOST} !^www. [NC]
                    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


                    You also mentioned previous attempts "keep failing". Could you tell us what is going wrong, since it may be something that will also cause the approach above to fail.






                    share|improve this answer













                    Try replacing:



                    RewriteCond %{HTTP_HOST} ^l-a-m.org [NC]
                    RewriteRule ^(.*)$ http://www.l-a-m.org/$1 [L,R=301]


                    with:



                    RewriteCond %{HTTP_HOST} !^www. [NC]
                    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


                    You also mentioned previous attempts "keep failing". Could you tell us what is going wrong, since it may be something that will also cause the approach above to fail.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 27 '18 at 12:14









                    JakeSteamJakeSteam

                    2,49152440




                    2,49152440













                    • Thanks JakeSteam, I've tried your code block but it takes the site down with the error message "too many redirects".

                      – mark clarke
                      Nov 27 '18 at 13:55













                    • @markclarke If my answer helped, please feel free to upvote / mark it as the answer!

                      – JakeSteam
                      Nov 27 '18 at 13:57



















                    • Thanks JakeSteam, I've tried your code block but it takes the site down with the error message "too many redirects".

                      – mark clarke
                      Nov 27 '18 at 13:55













                    • @markclarke If my answer helped, please feel free to upvote / mark it as the answer!

                      – JakeSteam
                      Nov 27 '18 at 13:57

















                    Thanks JakeSteam, I've tried your code block but it takes the site down with the error message "too many redirects".

                    – mark clarke
                    Nov 27 '18 at 13:55







                    Thanks JakeSteam, I've tried your code block but it takes the site down with the error message "too many redirects".

                    – mark clarke
                    Nov 27 '18 at 13:55















                    @markclarke If my answer helped, please feel free to upvote / mark it as the answer!

                    – JakeSteam
                    Nov 27 '18 at 13:57





                    @markclarke If my answer helped, please feel free to upvote / mark it as the answer!

                    – JakeSteam
                    Nov 27 '18 at 13:57


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53499265%2fwordpress-htaccess-www-redirect-fail%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Lallio

                    Futebolista

                    Jornalista