Mobile app version of vmapp.org
Login or Join
Carla537

: Google App Engine 301 Redirect I have a Google App Engine Java web app that I have setup with a custom domain from GoDaddy. The site can currently be reached at domain.com and www.domain.com.

@Carla537

Posted in: #301Redirect #Godaddy #GoogleAppEngine

I have a Google App Engine Java web app that I have setup with a custom domain from GoDaddy. The site can currently be reached at domain.com and domain.com. I am trying to have a 301 redirect occur whenever someone tries to access domain.com instead of domain.com. I have tried to use domain forwarding via GoDaddy, without success. How can I achieve this goal?


Here is my Google App Engine setup. I have added all of these records to the GoDaddy DNS Manger.



Here is the domain forwarding information I tried:

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Carla537

2 Comments

Sorted by latest first Latest Oldest Best

 

@Odierno851

Google does not support htaccess file. They support app.yaml file, which have different mod rewrite rule, but as far I know It will applicable only to one CNAME, it means if you have set example.com then those rewrite rules will not applicable to example.com.

You can use wildcard * in CNAME, which redirect all of your subdomain to your perferred domain name. For example if people access example.com/directory/ then it will automatically redirect to example.com/directory/ . The main drawback of wildcard is, it applied to all of your subdomain, it means you can't add any of content like images and blog in your subdomain, for example blog.example.com will redirect to example.com and images.example.com/puppy.jpg will redirect to example.com/puppy.jpg(Which may trigger 404 error). But If you don't have placed any of thing in your subdomain then wildcard will solve your problem.

And, If you just want to redirect example.com to example.com and not other subdirectory then you can use meta refresh tag which is client side solution. Or you can host your naked domain somwehere else(Github Pages, Firebase are free solution) and do 301 redirection.

10% popularity Vote Up Vote Down


 

@Jessie594

Update: There are 3 ways to do this.


htaccess
php to yaml with redirect
Within Google itself.



Specify the domain and subdomains you want to map.

Note: The naked domain and www subdomain are pre populated in the
form. A naked domain, such as example.com, maps to example.com. A subdomain, such as www, maps to www.example.com. Click Submit
mappings to create the desired mapping. In the final step of the Add
new custom domain form, note the resource records listed along with
their type and canonical name.


Full article on Google

Link to Custom Domains Login on Google

HTACCESS

Assuming you are on their Apache server you want to add this to your .htaccess file. This is for both, choose one. Replace example with your domain name.
#Force www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ www.example.com/ [L,R=301,NC]



#Force non-www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ example.com/ [L,R=301]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme