Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to permanently redirect `http://` and `www.` URLs to `https://`?

I have a Google App Engine project. On this project I have setup a custom domain and an SSL certificate. Therefore, I can use https://www.mysite.xxx, http://www.mysite.xxx and just the naked domain mysite.xxx.

Is it possible to permanently redirect the last two to always use the secure https:// domain using the developers console or do I just have to redirect in the code?

like image 265
Chez Avatar asked Nov 23 '15 19:11

Chez


People also ask

How do I permanently redirect a URL?

To redirect a site permanently, one should use a 301 redirect. This type of redirect is best for SEO purposes and also informs the search engines that the site has moved permanently. If you change your domain name and want to point to a different URL, a 301 redirect is your best choice.

How do I fix a URL with a permanent redirect?

There are two ways to fix these errors; Replace the redirect chain with a single 301 redirect. Instead of Page 1 > Page 2 > Page 3 > Page 4, the redirect becomes Page 1 > Page 4. Replace internal links to redirected pages with direct links to the final URL.


1 Answers

So you can add "secure: always" to your yaml file

https://cloud.google.com/appengine/docs/python/config/appconfig?hl=en#Python_app_yaml_Secure_URLs

like image 65
Tom Avatar answered Nov 09 '22 10:11

Tom