Setup Permanent 301 Redirects after moving to Https [on hold]












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













put on hold as off-topic by Krzysiek Dróżdż, Jacob Peattie, fuxia Jan 4 at 22:40


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third party plugins and themes are off topic, they are better asked about at their developers' support routes." – Krzysiek Dróżdż, Jacob Peattie, fuxia

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
    – Charles
    Jan 1 at 10:02
















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













put on hold as off-topic by Krzysiek Dróżdż, Jacob Peattie, fuxia Jan 4 at 22:40


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third party plugins and themes are off topic, they are better asked about at their developers' support routes." – Krzysiek Dróżdż, Jacob Peattie, fuxia

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
    – Charles
    Jan 1 at 10:02














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













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













share|improve this question











share|improve this question




share|improve this question










asked Jan 1 at 7:27









Abdullaziz HappyAbdullaziz Happy

112




112




put on hold as off-topic by Krzysiek Dróżdż, Jacob Peattie, fuxia Jan 4 at 22:40


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third party plugins and themes are off topic, they are better asked about at their developers' support routes." – Krzysiek Dróżdż, Jacob Peattie, fuxia

If this question can be reworded to fit the rules in the help center, please edit the question.




put on hold as off-topic by Krzysiek Dróżdż, Jacob Peattie, fuxia Jan 4 at 22:40


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third party plugins and themes are off topic, they are better asked about at their developers' support routes." – Krzysiek Dróżdż, Jacob Peattie, fuxia

If this question can be reworded to fit the rules in the help center, please edit the question.












  • Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
    – Charles
    Jan 1 at 10:02


















  • Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
    – Charles
    Jan 1 at 10:02
















Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
– Charles
Jan 1 at 10:02




Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
– Charles
Jan 1 at 10:02










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

















    • 1




      You can't use a mod_alias Redirect to redirect from HTTP to HTTPS - you need to use mod_rewrite (if using .htaccess). But since mod_rewrite directives are already being used by the WordPress front-controller, you shouldn't really be using Redirect for any redirects.
      – MrWhite
      Jan 1 at 22:07




















    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 Jan 1 at 11:43









        MrWhiteMrWhite

        1,52111015




        1,52111015

























            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

















            • 1




              You can't use a mod_alias Redirect to redirect from HTTP to HTTPS - you need to use mod_rewrite (if using .htaccess). But since mod_rewrite directives are already being used by the WordPress front-controller, you shouldn't really be using Redirect for any redirects.
              – MrWhite
              Jan 1 at 22:07


















            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

















            • 1




              You can't use a mod_alias Redirect to redirect from HTTP to HTTPS - you need to use mod_rewrite (if using .htaccess). But since mod_rewrite directives are already being used by the WordPress front-controller, you shouldn't really be using Redirect for any redirects.
              – MrWhite
              Jan 1 at 22:07
















            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 Jan 1 at 11:03









            Md. Ehsanul Haque KananMd. Ehsanul Haque Kanan

            725




            725








            • 1




              You can't use a mod_alias Redirect to redirect from HTTP to HTTPS - you need to use mod_rewrite (if using .htaccess). But since mod_rewrite directives are already being used by the WordPress front-controller, you shouldn't really be using Redirect for any redirects.
              – MrWhite
              Jan 1 at 22:07
















            • 1




              You can't use a mod_alias Redirect to redirect from HTTP to HTTPS - you need to use mod_rewrite (if using .htaccess). But since mod_rewrite directives are already being used by the WordPress front-controller, you shouldn't really be using Redirect for any redirects.
              – MrWhite
              Jan 1 at 22:07










            1




            1




            You can't use a mod_alias Redirect to redirect from HTTP to HTTPS - you need to use mod_rewrite (if using .htaccess). But since mod_rewrite directives are already being used by the WordPress front-controller, you shouldn't really be using Redirect for any redirects.
            – MrWhite
            Jan 1 at 22:07






            You can't use a mod_alias Redirect to redirect from HTTP to HTTPS - you need to use mod_rewrite (if using .htaccess). But since mod_rewrite directives are already being used by the WordPress front-controller, you shouldn't really be using Redirect for any redirects.
            – MrWhite
            Jan 1 at 22:07





            Popular posts from this blog

            Human spaceflight

            Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?

            張江高科駅