Hello everyone,
For fixing the canonical URLs for a site running on Apache, I have pulled the following redirection rules for redirecting http to https, non-www to www, index.php to www. Before I forward to the site owner I wanted to get a confirmation from you experts, if you think it is okay. Please have a look below and kindly guide if it will have the desired impact:
# Switch rewrite engine on
RewriteEngine On
# Redirect http to https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ [
domain.com...] [L,R=301]
# Redirect non-www to www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ [
domain.com...] [L,R=301]
# Redirect index.php to www
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php
RewriteRule ^index\.php$ / [L,R=301]
Sorry for the repeating the much answered question, as it was coupled with http/https so I though of better clarifying in the absence of a test server.
Warm Regards,
Vani