toggle menu

Hi anyone's,

I want to implement 301 redirection  http both version, index.php and https non www version to https www version.

Please suggest me!!

Regards

Rajnish

  • 1 like
  • 2 comments

Dhananjay Kumar10 Jan at 05:01

Hi,

Please try the below script , its work on all :

For www only :

if ($_SERVER['HTTP_HOST']=='xyz.com') {
$url = "http://www.". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header( "HTTP/1.1 301 Moved Permanently" );
header("Location: {$url}");
exit;
}

With HTTPS & WWW :

if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on" || $_SERVER['HTTP_HOST']=='domainname.com') {
$url = "https://www.". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header( "HTTP/1.1 301 Moved Permanently" );
header("Location: {$url}");
exit;
}

Try and suggest.

Dhananjay Kumar10 Jan at 05:01

Also, you may use this code

if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === "off") {
$url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header( "HTTP/1.1 301 Moved Permanently" );
header("Location: {$url}");
exit;
}

What is AMP and how its works?

Dhanavi |06 Apr at 05:04

Please anyone, explains with the example about the AMP.

  • 1 like
  • 2 comments

Vibhu Vikram Singh10 Apr at 07:04

d

Vibhu Vikram Singh10 Apr at 07:04

d

What is a canonical issue in SEO?

Rajnish Kumar |27 Mar at 05:03

Hi All,

What is a canonical issue in SEO? and how to Resolve the Canonical Issue on Your Website.

Regards

Rajnish

  • 0 like
  • 0 comment