Redirect through .htaccess file

Here’ s the logic to redirect particular page through .htaccess file.

RewriteCond %{HTTP_HOST} ^avidindiainc.com [NC]
RewriteRule ^(.*)$ http://www.avidindiainc.com/$1 [L,R=301]

as given above,
here avidindiainc.com is the url of the site you want to redirect. here if the url typed in the address bar is http://avidindiainc.com, it will redirect to http://www.avidindiainc.com.

the above given logic will work for apache webserver only as .htaccess file is supported by apache webserver and not IIS webserver. In case you have an IIS webserver here’s something you can do.

But this logic has to be written in php file. The logic follows as below:

<?php

if($_SERVER[‘SERVER_SOFTWARE’]==’Microsoft-IIS/6.0′){
if($_SERVER[‘HTTP_HOST’]!=’www.theartel.com’){
header( “HTTP/1.1 301 Moved Permanently” );
if($_SERVER[‘argv’])
header( “Location: http://www.&#8221;.$_SERVER[‘HTTP_HOST’].$_SERVER[‘PHP_SELF’].’?’.@implode(‘&’,$_SERVER[‘argv’]));
else
header( “Location: http://www.&#8221;.$_SERVER[‘HTTP_HOST’].$_SERVER[‘PHP_SELF’]);
}
}


?>

thanks,

Sachin