Jump to content

Htaccess file and redirection chaining


Recommended Posts

Posted (edited)

I logged into Google Search Console last night. For the umpteenth time, I received the message: "Fixes failed for Page indexing issues - Page with redirect."

I am trying to get non-www URLs and use the default htaccess file (trying to keep up with the updates).

Problem - Google scans the website URLs in this particular order, and chaining (which is The problem) via htaccess happens:

http://www.example.com -> https://www.example.com -> https://example.com

Fix: While I do not know how to write directives in the .htaccess, I spent hours to find a solution and finally succeeded.

    RewriteEngine On
    RewriteCond %{HTTPS} !on [OR]
    RewriteCond %{HTTP_HOST} ^www\. [NC]
    RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L,NE]

However, as I mentioned, I'm unfamiliar with the .htaccess file, and I am 100% sure that this could be written with a wild card. So, on this occasion, by default, can we have an option to avoid chain redirections of URLs?

Edited by Leftfield
Changed 302 to 301 to clarify
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...