Avoid landing page redirects error

Muhamad Sadik

Registered
Jun 20, 2018
1
0
1
Dubai
cPanel Access Level
Website Owner
Hi Gurus,

I am in trouble, I successfully got the 301 done but now it gives 2 redirections at landing page as follows;

Example issue:
If I type example.com in Google webpage speed test, now it is giving me errors;

Code:
Avoid landing page redirects for the following chain of redirected URLs.

http://example.com/

https://example.com/

https://www.example.com/
PLease note I have SSL installed and working,

I have lot of subdomains (each country one) but in below example I included only for sample, Can any one tell what did I do wrong below;
Code:
#Force non-www:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^www\.af.example\.com [NC]

RewriteRule ^(.*)$ [URL]https://af.example.com/$1[/URL] [L,R=301]

RewriteCond %{HTTP_HOST} ^www\.ax.example\.com [NC]

RewriteRule ^(.*)$ [URL]https://ax.example.com/$1[/URL] [L,R=301]

RewriteCond %{HTTP_HOST} ^www\.al.example\.com [NC]

RewriteCond %{HTTP_HOST} ^www\.zm.example\.com [NC]

RewriteRule ^(.*)$ [URL]https://zm.example.com/$1[/URL] [L,R=301]

RewriteCond %{HTTP_HOST} ^www\.zw.example\.com [NC]

RewriteRule ^(.*)$ [URL]https://zw.example.com/$1[/URL] [L,R=301]


## Server Defaults

ServerSignature Off

DefaultLanguage en-US

AddDefaultCharset utf-8

## Index Preferences

Options All -Indexes

IndexIgnore *

## GZIP Compression

<IfModule mod_deflate.c>

  # Compress HTML, CSS, JavaScript, Text, XML and fonts

  AddOutputFilterByType DEFLATE application/javascript

  AddOutputFilterByType DEFLATE application/rss+xml

  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject

  AddOutputFilterByType DEFLATE application/x-font

  AddOutputFilterByType DEFLATE application/x-font-opentype

  AddOutputFilterByType DEFLATE application/x-font-otf

  AddOutputFilterByType DEFLATE application/x-font-truetype

  AddOutputFilterByType DEFLATE application/x-font-ttf

  AddOutputFilterByType DEFLATE application/x-javascript

  AddOutputFilterByType DEFLATE application/xhtml+xml

  AddOutputFilterByType DEFLATE application/xml

  AddOutputFilterByType DEFLATE font/opentype

  AddOutputFilterByType DEFLATE font/otf

  AddOutputFilterByType DEFLATE font/ttf

  AddOutputFilterByType DEFLATE image/svg+xml

  AddOutputFilterByType DEFLATE image/x-icon

  AddOutputFilterByType DEFLATE text/css

  AddOutputFilterByType DEFLATE text/html

  AddOutputFilterByType DEFLATE text/javascript

  AddOutputFilterByType DEFLATE text/plain

  AddOutputFilterByType DEFLATE text/xml

</IfModule>

## EXPIRES CACHING ##

<IfModule mod_expires.c>

ExpiresActive On

ExpiresByType image/svg+xml "access plus 1 year"

ExpiresByType image/jpg "access plus 1 year"

ExpiresByType image/jpeg "access plus 1 year"

ExpiresByType image/gif "access plus 1 year"

ExpiresByType image/png "access plus 1 year"

ExpiresByType text/css "access plus 1 month"

ExpiresByType application/pdf "access plus 1 month"

ExpiresByType text/x-javascript "access plus 1 month"

ExpiresByType application/x-shockwave-flash "access plus 1 month"

ExpiresByType image/x-icon "access plus 1 year"

ExpiresDefault "access plus 2 days"


<filesMatch ".(css|js)$">

Header set Cache-Control "max-age=2628000, public"

</filesMatch>


</IfModule>

## Set Default PHP version

#AddHandler application/x-httpd-php56 .php

#AddHandler application/x-httpd-php70 .php


Header always set Access-Control-Allow-Origin "*"


<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /



RewriteCond %{HTTPS} off

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$

RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$

RewriteRule (.*) [URL]https://%[/URL]{HTTP_HOST}%{REQUEST_URI} [R=301,L]


RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$

RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$

RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$

RewriteRule . /index.php [L]

</IfModule>


<IfModule mod_rewrite.c>

   RewriteEngine On

   RewriteCond %{HTTP_HOST} ^example\.com$

   RewriteCond %{SERVER_PORT} 443

   RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$

   RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$

   RewriteRule ^(.*)$ https:\/\/www\.example\.com\/$1 [R=301,L]

</IfModule>

# php -- BEGIN cPanel-generated handler, do not edit

# NOTE this account's php is controlled via FPM and the vhost, this is a place holder.

# Do not edit. This next line is to support the cPanel php wrapper (php_cli).

# AddType application/x-httpd-ea-php56 .php .phtml



# php -- END cPanel-generated handler, do not edit
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
Hello @Muhamad Sadik,

I've seen past reports of this problem correspond to an internal redirect that's configured in the script that's installed on the website. Do you have a script installed on the website that uses it's own redirect? If so, try disabling that redirect from the script's configuration file or admin interface (refer to the script's documentation for instructions) to see if the issue persists.

Thank you.