Jump to content

EFitzpatr7

New Members
  • Posts

    4
  • Joined

  • Last visited

EFitzpatr7's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you for the code - I will look into implementing it later on once I get a spare moment. Unfortunately this was the client's idea, not ours. I understand the confusion that it will cause.
  2. 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. 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.