Redirecting Appspot URL to custom domain

785 views
Skip to first unread message

Nikhil P Naik

unread,
Jan 14, 2015, 12:23:46 AM1/14/15
to google-a...@googlegroups.com
I deployed a website (it consists of one index.html page and folders that contain js, image & css files)  on the app-engine and linked it to my custom domain. I configured the CNAME and the site is opening on my domain, but the original appspot URL is not being redirected to the custom domain. 

I did come across pages with similar questions which discussed about this problem. I tried implementing those, but they didn't seem to work.

Here is what I did, in the **app.yaml** file I replaced:

    - url: /.*
      static_files
: static
      upload
: static


with

    - url: /.*
      script
: main.application


and in the **main.py**, I erased all the content and added the following:


    import webapp2
   
from google.appengine.ext.webapp.util import run_wsgi_app
   
    application
= webapp2.WSGIApplication([
        webapp2
.Route('/', webapp2.RedirectHandler, defaults={'_uri':'http://subdomain.domain.com}),
    ], debug=False)
   
    def main():
        application.run()
   
    if __name__ == '
__main__':
        main()



But it doesn't seem to work. The appspot URL is not being redirected but my custom domain is working alright. What changes should I make in the above code to make the redirection possible?

Thanks!

Vinny P

unread,
Jan 21, 2015, 2:25:30 AM1/21/15
to google-a...@googlegroups.com
On Tue, Jan 13, 2015 at 11:23 PM, Nikhil P Naik <nik...@techarta.com> wrote:
        webapp2.Route('/', webapp2.RedirectHandler, defaults={'_uri':'http://subdomain.domain.com}),
    ], debug=False)
    
    def main():
        application.run()
    
    if __name__ == '
__main__':
        main()


But it doesn't seem to work. The appspot URL is not being redirected but my custom domain is working alright. What changes should I make in the above code to make the redirection possible?



First of all, your code is wrong: you didn't put an ending single quote mark after the .com, so Python thinks that the next few lines are part of the string. 

Just to clarify: you don't want the appspot URL to ever show up, correct? If an user visits your appspot.com address, you want them to always see your custom domain in their address bar? If so, I'd try a different solution such as this one: http://stackoverflow.com/a/8681704

 
 
-----------------
-Vinny P
Technology & Media Consultant
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com
 
Reply all
Reply to author
Forward
0 new messages