1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

order of redirections

Discussion in 'Apache' started by outrefranc, Oct 21, 2022.

  1. #1
    On my .htaccess file, I have simple redirections like this one:

    redirect 301 /oldpage.php https://www.mywebsite.com/new.page.php

    Then I've got got the big rewrite script force the "https" and the "www":

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteCond %{HTTPS} off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    Code (markup):
    My concern is that it makes 2 redirections. Even with the 301 one written above, my website makes the rewriting redirection first, and then the 301 one. 2 reirections are bad for SEO. Any suggestion on how to force the 301 to be made first?
    Thanks.
     
    outrefranc, Oct 21, 2022 IP
  2. seomanualsubmission

    seomanualsubmission Well-Known Member

    Messages:
    904
    Likes Received:
    128
    Best Answers:
    4
    Trophy Points:
    165
    #2
    You htaccess code is looking fine .... not need to change this.
     
    seomanualsubmission, Oct 22, 2022 IP
  3. outrefranc

    outrefranc Active Member

    Messages:
    94
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    93
    #3
    Yes, it's fine and it works. My problem lies with the google search console. I have many pages which google refuses because they're redirected twice. So I'm looking for a way to make the 301 redirection work before the rewriting script, so that there will be only one redirection.
     
    outrefranc, Oct 22, 2022 IP