1

I have a domain name : somewhere.com this domain is mapped to somewhere.appspot.com the Google hosting service.

Everything works well BUT When the users want to click on a link, they see the link as somewhere.appspot.com/somepage.php they get the right page but I would like them to see: somewhere.com/somepage.php

Any suggestions?

2 Answers 2

1

It sounds like you just mapped your domain to your appspot site. You have to set up appspot if you want to use a custom domain.

https://developers.google.com/appengine/docs/domain

1

You can use the HTML base tag in your webpage to make all the relative links point to somewhere.com instead of somewhere.appspot.com.

<base href="http://somewhere.com/">

You can also use the below PHP code to redirect the user to somewhere.com

$host = $_SERVER['HTTP_HOST'];
$request_uri = $_SERVER['REQUEST_URI'];

if(!startsWith($host, 'somewhere.appspot.com')){
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://somewhere.com".$request_uri); 
}

function startsWith($haystack,$needle,$case=true) {
    if($case){return (strcmp(substr($haystack, 0, strlen($needle)),$needle)===0);}
    return (strcasecmp(substr($haystack, 0, strlen($needle)),$needle)===0);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.