【发布时间】:2015-05-03 11:22:15
【问题描述】:
我正在将我的公司网站迁移到谷歌应用引擎,它的大部分内容都是静态内容,其中包含使用 python 生成的日期等小部分。我已经正确设置了所有内容,并且在应用引擎上运行良好。现在我想做一些与 SEO 相关的 URL 更改。
这是现在为网站提供服务的代码行。
app = webapp2.WSGIApplication([
('/', IndexPage),
('/discover', DiscoverPage),
('/about', AboutPage),
('/help', HelpPage),
('/terms-and-privacy', TermsPage)
], debug=True)
为每个页面定义了这样的类。
class DiscoverPage(webapp2.RequestHandler):
def get(self):
template_values = {
'bodyclass': 'discover',
}
template = JINJA_ENVIRONMENT.get_template('discover.html')
self.response.write(template.render(template_values))
现在我想要实现的目标是:
- 当从
www.domain.com访问网站时,我想将其重定向到domain.com。
我在应用引擎开发者控制台添加了 www 和非 www 映射,该站点目前可以从 www 和非 www url 访问。但我只想要
non www版本
- 当 URL 有斜杠时,将其剥离并发送到不带斜杠的版本。
现在
domain.com/discover可以正常工作,但domain.com/discover/会以 404 结束。
我对 python webapps 没有太多经验,我的背景主要是 apache/nginx 服务器和 php 。 AppEngine 是否有类似 htaccess rules 或 nginx rewrites 的信息?
【问题讨论】:
标签: python google-app-engine webapp2