重定向* .appspot.com到自定义域:Google应用引擎(Django) [英] Redirect *.appspot.com to custom domain: Google app engine (Django)

查看:107
本文介绍了重定向* .appspot.com到自定义域:Google应用引擎(Django)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  url.py 
我将直接在这里放置一些我的示例代码
(r'^ robots \.txt $','myapp.views.robots'),
(r'^ $','myapp.views.home'),

views.py

def home(request):
...我的代码
返回render_to_response(请求,'myapp / home.html',locals())

models.py
class user_sessions(db.Model):
email_id = db.StringProperty(default ='')
user_id = db.IntegerProperty(default = 0)
class Meta:
db_table ='user_sessions'
verbose_name ='User Session'
verbose_name_plural ='User Sessions'
def __unicode __(self):
return self.user_id

我的网站托管在 mydomain.com &安培;我也可以访问使用 mydomain.appspot.com 。但是在 SEO 中面临的主要问题。



robots.txt 我打电话给我的 mydomain.com/sitemap.xml



但是当我在google&看到结果,然后它显示结果与appspot url,但不是与我的实际域名url。



然后我想到将appspot.com重定向到mydomain.com



但是我真的不知道如何在全球范围内在我的应用程序中执行。



任何人都可以帮助相同?

解决方案

如果您的自定义域名正在运行,请在您的网页上添加规范标签。当相同的内容可以从多个域使用时,应该通知搜索引擎您喜欢哪个域。

    

https://en.wikipedia.org/wiki/Canonical_link_element


I'm directly putting here some sample code of mine to get better picture.

url.py

(r'^robots\.txt$', 'myapp.views.robots'),
(r'^$', 'myapp.views.home'),

views.py

def home(request):
...my code
return render_to_response(request, 'myapp/home.html', locals())

models.py
class user_sessions(db.Model):
   email_id = db.StringProperty(default='')
   user_id = db.IntegerProperty(default=0)
   class Meta:
      db_table = 'user_sessions'
      verbose_name = 'User Session'
      verbose_name_plural = 'User Sessions'
   def __unicode__(self):
      return self.user_id

My website is hosted on mydomain.com & I can access the using mydomain.appspot.com too. But the main issue i'm facing with SEO.

in robots.txt i'm calling my mydomain.com/sitemap.xml

but when i search on google & sees the result then it shows the result with appspot url but not with my actual domain url.

Then i got an idea of to redirect appspot.com to mydomain.com

But really i don't know how to do that globally in my app.

Could anyone help out for the same?

解决方案

If your custom domain is working, add a canonical tag to your pages. This should notify search engines which domain you prefer when same content is available from multiple domains.

<link rel="canonical" href="https://example.com/" />

https://en.wikipedia.org/wiki/Canonical_link_element

这篇关于重定向* .appspot.com到自定义域:Google应用引擎(Django)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆