View Categories

HTTPS redirections without redirect chain

< 1 min read

Redirecting to non-www https website version, without redirect chain.

(Domain name in the example bellow is diligent.biz, change it for other websites)

<IfModule mod_rewrite.c>
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} ^www\.diligent\.biz [NC]
    RewriteRule (.*) https://diligent.biz/$1 [L,R=301]
</IfModule>

Place this code in the root .htaccess of the site. Here is what it’s doing:

  • Checks if mod_rewrite is available
  • Checks if HTTPS is off, or if the request includes www
  • If either condition matches, the request qualifies and is redirected to the https/non-www address
Leave a Reply 0

Your email address will not be published. Required fields are marked *