Results 1 to 2 of 2

Thread: .htaccess send user from .com to .co.uk

  1. #1
    Squeeler Vini's Avatar
    Join Date
    Jul 2003
    Location
    Sheffield
    Posts
    1,769
    Thanks
    44
    Thanked
    8 times in 8 posts

    .htaccess send user from .com to .co.uk

    I have 2 domains the same, with .com and .co.uk... I've got the Google Maps API key for one domain and not the other... Is there anyway to send all visitors to say the .co.uk 'domain' so that there is no issue with the Google Maps API?

    if someone visits the .com and goes to the contact page, the google api cries.

    if someone visits the same on the .co.uk it works, because of the key.

    i was wondering if there was any way to always force the user to the .co.uk version... even if they hit the .com

  2. #2
    Member
    Join Date
    Jan 2007
    Location
    Manchester
    Posts
    56
    Thanks
    0
    Thanked
    0 times in 0 posts
    There should be a really simple and clean way of doing this through .htaccess but I can't think of it! Redirect 301s will go into a loop, Rewrites don't change the url client side, and you can't use <VirtualHost>s in .htaccess files

    Best I came up with was this in javascript:

    PHP Code:
      <script language="JavaScript" type="Text/JavaScript">
        var 
    url document.location.href;
        if(
    url.match(/domain\.com/)){
            
    url url.replace(/domain\.com/, "domain.co.uk");
            
    document.location url;
        }
      
    </script> 
    To be fair tho, your site shouldn't be using multiple domains anyway. It's a bad way of doing things, because after time you'll always get into trouble like this. (Although usually the trouble is with cookies). You should make it so all of your other domains have this in their .htaccess file:
    PHP Code:
    Redirect 301 http://domain.co.uk/ 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Caller ID on your PC
    By mattc in forum Help! Quick Relief From Tech Headaches
    Replies: 29
    Last Post: 22-09-2010, 11:52 AM
  2. Windows - a brief guide inside
    By Paul Adams in forum Software
    Replies: 31
    Last Post: 23-06-2007, 03:14 PM
  3. Windows User Name & "My Documents"
    By Stumpy2 in forum Software
    Replies: 9
    Last Post: 30-03-2006, 03:20 PM
  4. .co.uk or .com
    By Zak33 in forum General Discussion
    Replies: 56
    Last Post: 25-07-2005, 06:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •