Setup Permanent 301 Redirects after moving to Https












2














i moved my site from http to https
now i want to redirect the user into the new url but evry time i'm trying to edit .htaccess file i'm getting an error



this is the working file content where xxxz is site name



# 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
RewriteCond %{HTTP_HOST} ^xxxz.qa$ [OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]


what i'm trying to edit is to add the following code in the top of the file as i read



RewriteEngine on
RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]


but its not working so what do u think










share|improve this question







New contributor




Abdullaziz Happy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
    – Charles
    2 hours ago
















2














i moved my site from http to https
now i want to redirect the user into the new url but evry time i'm trying to edit .htaccess file i'm getting an error



this is the working file content where xxxz is site name



# 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
RewriteCond %{HTTP_HOST} ^xxxz.qa$ [OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]


what i'm trying to edit is to add the following code in the top of the file as i read



RewriteEngine on
RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]


but its not working so what do u think










share|improve this question







New contributor




Abdullaziz Happy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
    – Charles
    2 hours ago














2












2








2


1





i moved my site from http to https
now i want to redirect the user into the new url but evry time i'm trying to edit .htaccess file i'm getting an error



this is the working file content where xxxz is site name



# 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
RewriteCond %{HTTP_HOST} ^xxxz.qa$ [OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]


what i'm trying to edit is to add the following code in the top of the file as i read



RewriteEngine on
RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]


but its not working so what do u think










share|improve this question







New contributor




Abdullaziz Happy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











i moved my site from http to https
now i want to redirect the user into the new url but evry time i'm trying to edit .htaccess file i'm getting an error



this is the working file content where xxxz is site name



# 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
RewriteCond %{HTTP_HOST} ^xxxz.qa$ [OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]


what i'm trying to edit is to add the following code in the top of the file as i read



RewriteEngine on
RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]


but its not working so what do u think







htaccess ssl






share|improve this question







New contributor




Abdullaziz Happy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Abdullaziz Happy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Abdullaziz Happy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 5 hours ago









Abdullaziz Happy

112




112




New contributor




Abdullaziz Happy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Abdullaziz Happy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Abdullaziz Happy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
    – Charles
    2 hours ago


















  • Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
    – Charles
    2 hours ago
















Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
– Charles
2 hours ago




Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
– Charles
2 hours ago










2 Answers
2






active

oldest

votes


















1















RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]



This will result in a redirect loop as it will repeatedly redirect https://www.xxxz.com.qa/<url> to https://www.xxxz.com.qa/<url> again and again...



If you want to redirect from HTTP then you need to check that the request was for HTTP before redirecting to HTTPS. For example:



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


No need for the NC flag, as you are simply matching everything anyway.





However, this conflicts with the existing directives at the end of your file:




RewriteCond %{HTTP_HOST} ^xxxz.qa$ [OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]



These directives should probably be deleted. (Fortunately, they probably aren't doing anything anyway - because they are after the WordPress front-controller.)






share|improve this answer





























    0














    The best way for setting up Permanent 301 Redirects is by editing .htaccess with the required redirection code. Follow these steps:




    1. Open your cPanel account.

    2. Click on File Manager under Files section.

    3. Click on public_html directory in the left sidebar.

    4. Search for the .htaccess file. Right-click on it. Click on Edit.

    5. A pop up box will appear. Click on Edit.


    6. A new tab will be opened. Here, you have to add the
      redirect code. For example, your old page is
      https://yoursite.com/old-page.htm, and the new page is
      https://yoursite.com/new-page.htm. In this case, the redirect code
      will be:



      Redirect 301 /old-page.htm/ /new-page.htm



    You can find more information about these steps right here.






    share|improve this answer





















      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "110"
      };
      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: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      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
      });


      }
      });






      Abdullaziz Happy is a new contributor. Be nice, and check out our Code of Conduct.










      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f324345%2fsetup-permanent-301-redirects-after-moving-to-https%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1















      RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
      RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
      RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]



      This will result in a redirect loop as it will repeatedly redirect https://www.xxxz.com.qa/<url> to https://www.xxxz.com.qa/<url> again and again...



      If you want to redirect from HTTP then you need to check that the request was for HTTP before redirecting to HTTPS. For example:



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


      No need for the NC flag, as you are simply matching everything anyway.





      However, this conflicts with the existing directives at the end of your file:




      RewriteCond %{HTTP_HOST} ^xxxz.qa$ [OR]
      RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
      RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
      RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
      RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]



      These directives should probably be deleted. (Fortunately, they probably aren't doing anything anyway - because they are after the WordPress front-controller.)






      share|improve this answer


























        1















        RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
        RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
        RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]



        This will result in a redirect loop as it will repeatedly redirect https://www.xxxz.com.qa/<url> to https://www.xxxz.com.qa/<url> again and again...



        If you want to redirect from HTTP then you need to check that the request was for HTTP before redirecting to HTTPS. For example:



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


        No need for the NC flag, as you are simply matching everything anyway.





        However, this conflicts with the existing directives at the end of your file:




        RewriteCond %{HTTP_HOST} ^xxxz.qa$ [OR]
        RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
        RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
        RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
        RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]



        These directives should probably be deleted. (Fortunately, they probably aren't doing anything anyway - because they are after the WordPress front-controller.)






        share|improve this answer
























          1












          1








          1







          RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
          RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
          RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]



          This will result in a redirect loop as it will repeatedly redirect https://www.xxxz.com.qa/<url> to https://www.xxxz.com.qa/<url> again and again...



          If you want to redirect from HTTP then you need to check that the request was for HTTP before redirecting to HTTPS. For example:



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


          No need for the NC flag, as you are simply matching everything anyway.





          However, this conflicts with the existing directives at the end of your file:




          RewriteCond %{HTTP_HOST} ^xxxz.qa$ [OR]
          RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
          RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
          RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
          RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]



          These directives should probably be deleted. (Fortunately, they probably aren't doing anything anyway - because they are after the WordPress front-controller.)






          share|improve this answer













          RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
          RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
          RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]



          This will result in a redirect loop as it will repeatedly redirect https://www.xxxz.com.qa/<url> to https://www.xxxz.com.qa/<url> again and again...



          If you want to redirect from HTTP then you need to check that the request was for HTTP before redirecting to HTTPS. For example:



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


          No need for the NC flag, as you are simply matching everything anyway.





          However, this conflicts with the existing directives at the end of your file:




          RewriteCond %{HTTP_HOST} ^xxxz.qa$ [OR]
          RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
          RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
          RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
          RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]



          These directives should probably be deleted. (Fortunately, they probably aren't doing anything anyway - because they are after the WordPress front-controller.)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 1 hour ago









          MrWhite

          1,49411015




          1,49411015

























              0














              The best way for setting up Permanent 301 Redirects is by editing .htaccess with the required redirection code. Follow these steps:




              1. Open your cPanel account.

              2. Click on File Manager under Files section.

              3. Click on public_html directory in the left sidebar.

              4. Search for the .htaccess file. Right-click on it. Click on Edit.

              5. A pop up box will appear. Click on Edit.


              6. A new tab will be opened. Here, you have to add the
                redirect code. For example, your old page is
                https://yoursite.com/old-page.htm, and the new page is
                https://yoursite.com/new-page.htm. In this case, the redirect code
                will be:



                Redirect 301 /old-page.htm/ /new-page.htm



              You can find more information about these steps right here.






              share|improve this answer


























                0














                The best way for setting up Permanent 301 Redirects is by editing .htaccess with the required redirection code. Follow these steps:




                1. Open your cPanel account.

                2. Click on File Manager under Files section.

                3. Click on public_html directory in the left sidebar.

                4. Search for the .htaccess file. Right-click on it. Click on Edit.

                5. A pop up box will appear. Click on Edit.


                6. A new tab will be opened. Here, you have to add the
                  redirect code. For example, your old page is
                  https://yoursite.com/old-page.htm, and the new page is
                  https://yoursite.com/new-page.htm. In this case, the redirect code
                  will be:



                  Redirect 301 /old-page.htm/ /new-page.htm



                You can find more information about these steps right here.






                share|improve this answer
























                  0












                  0








                  0






                  The best way for setting up Permanent 301 Redirects is by editing .htaccess with the required redirection code. Follow these steps:




                  1. Open your cPanel account.

                  2. Click on File Manager under Files section.

                  3. Click on public_html directory in the left sidebar.

                  4. Search for the .htaccess file. Right-click on it. Click on Edit.

                  5. A pop up box will appear. Click on Edit.


                  6. A new tab will be opened. Here, you have to add the
                    redirect code. For example, your old page is
                    https://yoursite.com/old-page.htm, and the new page is
                    https://yoursite.com/new-page.htm. In this case, the redirect code
                    will be:



                    Redirect 301 /old-page.htm/ /new-page.htm



                  You can find more information about these steps right here.






                  share|improve this answer












                  The best way for setting up Permanent 301 Redirects is by editing .htaccess with the required redirection code. Follow these steps:




                  1. Open your cPanel account.

                  2. Click on File Manager under Files section.

                  3. Click on public_html directory in the left sidebar.

                  4. Search for the .htaccess file. Right-click on it. Click on Edit.

                  5. A pop up box will appear. Click on Edit.


                  6. A new tab will be opened. Here, you have to add the
                    redirect code. For example, your old page is
                    https://yoursite.com/old-page.htm, and the new page is
                    https://yoursite.com/new-page.htm. In this case, the redirect code
                    will be:



                    Redirect 301 /old-page.htm/ /new-page.htm



                  You can find more information about these steps right here.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 1 hour ago









                  Md. Ehsanul Haque Kanan

                  785




                  785






















                      Abdullaziz Happy is a new contributor. Be nice, and check out our Code of Conduct.










                      draft saved

                      draft discarded


















                      Abdullaziz Happy is a new contributor. Be nice, and check out our Code of Conduct.













                      Abdullaziz Happy is a new contributor. Be nice, and check out our Code of Conduct.












                      Abdullaziz Happy is a new contributor. Be nice, and check out our Code of Conduct.
















                      Thanks for contributing an answer to WordPress Development Stack Exchange!


                      • 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.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • 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%2fwordpress.stackexchange.com%2fquestions%2f324345%2fsetup-permanent-301-redirects-after-moving-to-https%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

                      Understanding the information contained in the Deep Space Network XML data?

                      Ross-on-Wye

                      Eastern Orthodox Church