如何从appspot域重定向到自定义域?
我发现 Amir 发表了有关将请求从 google.appspot 域重定向到自定义域的帖子。我的问题是你使用 Web2py 将这样的东西放在哪里?
**To just add a custom domain, just follow the instructions here: http://code.google.com/appengine/articles/domains.html
And once that works, you can put a check in your code to forward anyone landing on the appspot.com domain to your domain: (example in python)
def get(self):
if self.request.host.endswith('appspot.com'):
return self.redirect('www.jaavuu.com', True)
# ... your code ...**
I found this post from Amir in regards to redirecting request from google.appspot domain to the custom domain. My question is where do you put something like this using Web2py?
**To just add a custom domain, just follow the instructions here: http://code.google.com/appengine/articles/domains.html
And once that works, you can put a check in your code to forward anyone landing on the appspot.com domain to your domain: (example in python)
def get(self):
if self.request.host.endswith('appspot.com'):
return self.redirect('www.jaavuu.com', True)
# ... your code ...**
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(3)
梦里南柯2024-12-31 02:22:53
对于 webapp2,这与我所做的类似,其中 BaseHandler 是我所有处理程序的类型:
class BaseHandler(webapp2.RequestHandler):
def __init__(self, request, response):
self.initialize(request, response)
if request.host.endswith('appspot.com'):
query_string = self.request.query_string
redirect_to = 'https://www.example.com' + self.request.path + ("?" + query_string if query_string else "")
self.redirect(redirect_to, permanent=True, abort=True)
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
在第一个模型文件的开头,您可以执行以下操作:
这将保留整个原始 URL,但将 yourdomain.appspot.com 替换为 www.yourdomain.com 除外。请注意,
URL()
将自动填充当前控制器和函数,但您必须显式传递当前 request.args 和 request.vars 以确保它们得到保留。At the beginning of your first model file, you can do:
This will preserve the entire original URL, except for replacing yourdomain.appspot.com with www.yourdomain.com. Note,
URL()
will automatically fill in the current controller and function, but you have to explicitly pass the current request.args and request.vars to make sure they get preserved.