Skip to content

WeaverStever/Redirect-domain-to-www.domain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

How to redirect a root domain to the www version.

The problem:

I have a domain from Google, I want to keep the root domain at Google to take advantage of their email functionality, but the www address is hosted on an Apache2 server elsewhere. I have the www version working by providing the www alias to the Google DNS, but this leaves the root domain with no host.

Again, my goal is to keep DNS at Gootle, so a Google solution seems appropriate, but an .htaccess 301 redirect does not seem to be an option with Gcloud / App Engine.

For this solution, the first step is to create a Python2.7 account for Quickstart for Python App Engine Standard Environment. If you are using a later version of Python, perhaps these documents will help you adapt this solution to your version.

If you followed the Quickstart, you should have a website working at http://[YOUR_PROJECT_ID].appspot.com. Download or clone this GIT.

You will need your Gcloud [YOUR_PROJECT_ID] (not the entire URL), add the ID to the gae_deploy.sh file in the python27 directory.

In the python27/code directory, edit main.py file and modify https://www.example.com/ to your desired URL. Here is the documentation for the web.py redirect. http://webpy.org/cookbook/redirect%2Bseeother

You should replace the favicon.ico file with your favicon, I provided a favicon because Gcloud raises an exception if it does not find one.

You should now be able to open a terminal in the python27 directory and run the gae_deploy.sh file (sh gae_deploy.sh). You might have to make the file executable. If it is working, it should start the Gcloud upload process. On completion, your appspot url should be redirecting to your www subdomain.

Navigate to https://console.cloud.google.com/appengine and select "Settings" in the left menu. Select the tab, "Custom domains". Follow the instrucions on how to map your root domain to your App Engine host.

About

A redirect using web.py on Google app engine

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published