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
Rajnish Kumar |07 Aug at 05:08
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
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.