Redirecting to a single domain

If your website is running under several domain names, it is recommended to choose one main domain and make the redirection from other domains to the selected one. Place this part of the code at the beginning of your PHP script.


<?php
$redirect  
= 'platon.sk';
$http_host = @$_SERVER['HTTP_HOST'];
$req_uri   = @$_SERVER['REQUEST_URI'];
if (
strlen($http_host) > 0
    
&& strcasecmp($http_host, $redirect))
{
    
header("Location: http://$redirect$req_uri");
    exit;
}
?>

The main advantages of this solution are mostly within the area of Search Engine Optimization (SEO):

  • the same content sits on a single website (domain), which is what search engines like;
  • the Google PageRank value is not split between several pages, but adds up for the one main page;
  • as a result, the indexing of your website should improve, and so should its ranking in search engines.

Solution using the .htaccess

You can solve this problem using the .htaccess file as well.

Redirect from www to non-www:


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^ %{REQUEST_SCHEME}://%1%{REQUEST_URI} [R=301,L]
</IfModule>

Redirect from non-www to www:


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ %{REQUEST_SCHEME}://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>

helpdesk

we are ready to help

currently online

agents online 2 / 6

Platon Technologies

How can we help you?

We accept problem reports and any other feedback related to the use of our products and services.

 

helpdesk@platon.net +421 222 111 321

In case you need any help, contact us by e-mail or by phone.

  • By phone from 8:30 - 17:30
  • Sometimes even on weekends
  • Simple human approach
  • Even complex problems solved
contact form

Give our online help center a try. You will find more than:

  • 6 categories
  • 60 manuals
  • 23 e-mail settings
  • 8 programming tips
go to help center

Questions about our products or any specific request? Contact us.

We are checking whether the message is spam. Please wait...

Thanks for your message

If necessary, we will contact you.

Sending the message failed

Please contact us at helpdesk@platon.net.

NEWSLETTER

Thanks for subscribing

Subscription has failed