Jump to content

EFitzpatr7

New Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by EFitzpatr7

  1. Thank you for the code - I will look into implementing it later on once I get a spare moment.

     

    PS: The logo with the different domain names doesn't make sense anymore. If someone goes to domain1.com then they'll be redirected to domain1.co.uk but see the .com logo. That's confusing.


    * Or two. The www and non-www can share cookies if the session cookie parameters are configured properly, but the .com and .co.uk definitely cannot.

     

    Unfortunately this was the client's idea, not ours. I understand the confusion that it will cause.

  2. Without duplicating the website? I don't know any way for you to keep four distinct sites, with support from search engines, without being penalized for duplication, in a way that you could feasibly have four logos. Duplicating the website is the only way you could have the four sites so each can have their own logo.

     

    Internationalization is probably the answer here. Why do you need four domains? What's the difference between them? You know that domain1 vs domain2 and .com vs .co.uk doesn't matter in any technical ways, right? One of those four combinations will be the most appropriate domain name for you to use.

     

    If you want to vary the logo but are willing to give up the association with the domain name, you could vary it by the user's IP address: domain1/2.com for US visitors, domain1/2.co.uk for non-US visitors. Or something like that.

    The reason why we wanted to do it on a per-domain basis is for the sheer fact that the logos have the TLD within them. For example, the logo shows WEBSITE_NAME_HERE.co.uk / WEBSITE_NAME_HERE.com

     

    However, the company in question have 2 different company names, each with 2 logos.

     

    The business itself is based in the UK, so domain1.co.uk would be the primary domain, but the client has asked for each of the logos to be used when the user enters a specific domain, which is where the 3 extra domains come in.

     

    I have been provided with a code to redirect the URL within the PHP rather than creating a 301 with the domain registrar. Would this complete the desired task?

    <?php
    session_start();
    $_SESSION['url'] = $_SERVER['HTTP_HOST'];
    
    // redirect done via PHP
    if ($_SERVER['HTTP_HOST'] == 'www.WEBSITE_URL_HERE.com') {
      header("HTTP/1.1 301  Moved Permanently');  
      header("location: http://www.WEBSITE_URL_HERE.co.uk');
      exit;
    }
    
    function logoSwap(){ 
    switch($_SESSION['url']) { 
    case 'WEBSITE_URL_HERE.com': 
    $logo = "WEBSITE_URL_HERE/wp-content/uploads/2016/01/logo-red.png"; 
    break; 
    case 'www.WEBSITE_URL_HERE.com': 
    $logo = "WEBSITE_URL_HERE/wp-content/uploads/2016/01/logo-red.png"; 
    break; 
    case 'WEBSITE_URL_HERE.co.uk': 
    $logo = "WEBSITE_URL_HERE/wp-content/uploads/2015/09/logo.png"; 
    break; 
    case 'www.WEBSITE_URL_HERE.co.uk': 
    $logo = "WEBSITE_URL_HERE/wp-content/uploads/2015/09/logo.png"; 
    break; 
    default: 
    $logo = "WEBSITE_URL_HERE/wp-content/uploads/2015/09/logo.png"; 
    break; 
    } 
    return $logo; 
    } 
    ?>
  3. If there are any redirections then it should be easy to spot: go to one domain, see if you're redirected to another domain.

     

    But if you don't have those redirections then you'll suffer with SEO: having four domains with the same content is not good. You should pick one and go with it, either by redirecting everyone to it or using a rel=canonical to point to the "main" domain's version of the page. Either way, though, search engines will only show one of the sites in their search results.

     

    Varying the image on www or non-www domains is... silly. I have no idea why you would want to do that. Varying by .co.uk or .com? Sure. But that sounds like an internationalization thing, and those kinds of issues are handled differently than showing the same site on multiple domains.

     

    What I meant was I wanted to vary the logo based upon the .co.uk or the .com domain.

     

    For example, we have:

     

    • domain1.co.uk
    • domain1.com
    • domain2.co.uk
    • domain2.com

     

    We want to have a different logo for each of those 4 domains without duplicating the website. Is this possible?

  4. I am posting here for generic coding support rather than WordPress. I originally posted this on the WordPress Development Stack Exchange and was supported until it was no longer a WordPress related matter.


     


    The agency I work for are trying to get a client's logo to change based upon the incoming URL.


     


    Now, we have 4 different URLs, therefore 4 different logos.


     


    Currently, we are using an if/else statement, and the default logo is being bought through to the header.


     


    The if/else statement we are using is as follows:



    <?php
    if(!empty($image)) {
    echo '<h1>WEBSITE_NAME_HERE</h1>';
    }
    else {
    echo '<img src="'.logoSwap().'" alt="Localised Logo">';
    }
    ?>

    The problem now lies with the logo not actually changing.


     


    We are using a switch/case statement to actually specify the image paths and the incoming domains, and in order for the logoSwap() function to actually be declared:



    <?php
    function logoSwap(){
    switch($_SERVER['HTTP_HOST']) {
    case 'WEBSITE_URL_HERE.com':
    $logo = "WEBSITE_URL_HERE/wp-content/uploads/2016/01/logo-red.png";
    break;
    case 'www.WEBSITE_URL_HERE.com':
    $logo = "WEBSITE_URL_HERE/wp-content/uploads/2016/01/logo-red.png";
    break;
    case 'WEBSITE_URL_HERE.co.uk':
    $logo = "WEBSITE_URL_HERE/wp-content/uploads/2015/09/logo.png";
    break;
    case 'www.WEBSITE_URL_HERE.co.uk':
    $logo = "WEBSITE_URL_HERE/wp-content/uploads/2015/09/logo.png";
    break;
    default:
    $logo = "WEBSITE_URL_HERE/wp-content/uploads/2015/09/logo.png";
    break;
    }
    return $logo;
    }
    ?>

    The .com domain is using a 301 redirect which is pulling it directly to the .co.uk domain, however the logo isn't changing when accessed from the .com domain. Could it simply be the fact that it is coming in via a 301 redirect?


     


    For example, I will type in mywebsite.com and I will get redirected to mywebsite.co.uk, however it displays the same logo on both.


     


    It has been suggested to me to set a cookie (i.e. com=1) on the redirect, and then simply do the logoSwap() function as a simple "if cookie set, show red, else show normal" code.


     

    Unfortunately, I don't quite know how I'm going to do this, so this is where I need your help.

     

    Any help would be much appreciated.

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.