skip to Main Content

I have a simple website at https://karra-asynk.appspot.com which has been live for many years. Recently I bought a domain http://asynk.io/ and set it up to point to my appengine application. The problem is when I search for ‘asynk’ or any related keyword, google only shows the appspot urls in the search results. Anyway I can point all of those to my custom domain?

3

Answers


  1. You can add a check for the requested domain and if it’s the appspot subdomain, then redirect to the same path under the new domain. After that you just need to wait. It takes time to update the Google index and it depends the amount of links to your site (that Google knows of), so if your site is listed in places you have control of – update the links to the new domain.

    You may also consider serving different robots.xml depending on the requested domain – for the old subdomain serve it with “Disallow: /” to prevent indexing it, however that doesn’t necessarily mean that the new domain will be listed in Google instead for the same search, at least not until some time has passed.

    Login or Signup to reply.
    1. Make sure you are redirecting your .appspot.com requests to your new domain with the 301 redirect code.

    2. You can also use Google Webmaster’s “Change of address” tool.

    Login or Signup to reply.
  2. Just add middleware at the top of MIDDLEWARE_CLASSES of settings.py

    in my case

    MIDDLEWARE_CLASSES = {
      'myapp.models.WWWRedirectMiddleware',
    }
    

    in models.py

    from django.http import HttpResponsePermanentRedirect //Permanent Redirect status - 301 
    
    class WWWRedirectMiddleware(object):
        def process_request(self, request):
            if request.META['HTTP_HOST'].endswith('appspot.com'):
                logging.info('---Redirecting to domain.com----')
                return HttpResponsePermanentRedirect('http://domain.com' + request.META['PATH_INFO'])
    

    Note: The static files cannot be handled using this.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search