I’m looking to host my site of several domains, .co.uk and .com.au for example.

currently .com.au is my default and only domain, I was going to add uk as an alias domain. If I wanted to do things like change the logo based on the domain access via how can I do this?

So you're wanting different content based on the value of $_SERVER['SERVER_NAME']?

    NZ_Kiwis

    <?php
        $imgurl = "";
        if ($_SERVER["SERVER_NAME"] == "mydomain.co.uk"){
            $imgurl = "file path to mydomain.co.uk image";
        } else {
            $imgurl = "file path to mydomain.au image";
        }
    ?>
    
    <img src="<?=$imgurl ?>" />
    
    

    Alternatively you could store each domain's images in a seperate folder and declare
    the file path to the image folder in the same way. This is in fact the better approach.
    The more structured approach.

    You can do the same with style sheets too.

      Great thanks. Seems very logical and easy.

      how about language conversion is there and easy and free way to do this?

      NZ_Kiwis
      You could store the text content in a database and retrieve it again depending on the $_SERVER["SERVER_NAME"].
      Have a DomainRef column in a content table called PageContent so that you can apply domain condition to the select query. Name these elements what you will.

      You might have some thing like:

      Table name.. PageContent
      ID.. A unique identifier column
      DomainRef.. Either mydomain.co.uk or mydomain.au
      PageRef.. The web page name
      TextContenRef.. Some way of identifying the content on the page.
      (Give the HTML Div or Table a unique name attribute)
      TextContent.. The actual text content that appears on the page.

      The retrieval stored proc (in MSSql) would be something like this

      CREATE PROCEDURE [dbo].[GetTextContent] @DomainRef varchar(20),
       @PageRef varchar(20), 
       @TextContentRef varchar(20)
      AS
      BEGIN
      SET NOCOUNT ON;
      BEGIN TRANSACTION
      
      declare @error int;
      select @error = @@error;
      
      if @error = 0
      
      begin
      
      select TextContent from [PageContent] where DomainRef = @DomainRef 
      and PageRef = @PageRef and TextContentRef = @TextContentRef
      
      select @error = @@error
      
      end
      
      if @error <> 0 goto ERR_HANDLER
      
      COMMIT TRANSACTION
      
      Return 0
      
      ERR_HANDLER:
         execute GetErrorInfo; <-- an error handler proc
         ROLLBACK TRANSACTION 
         Return 1
      END
      
      

      As for the language translation you could just use Google to derive the language content.

      There are, of course, other approaches.

      You could also consider having seperate databases for different languages.
      Same schema different content.
      You could configure the connection string on the basis of $_SERVER["SERVER_NAME"].

      Why database? Because all you have to do to change the content is alter the database record
      and it immediately becomes available to the user base without having to touch the site.

        NZ_Kiwis how about language conversion is there and easy and free way to do this?

        If you mean the actual translation from one language to another, you could always try https://translate.google.com/ .

        A good idea though is to translate from language A to language B, then take the result and submit it to translate back into language A and make sure the meaning is still the same. If not, you may want to tinker with the original text to resolve ambiguities and such, or try other translation services, or pay someone who really knows what they're doing. 🙂 (Of course, some of that depends on how critical it is that the translation is exactly correct, versus being "good enough".)

          Write a Reply...