0
我在google appengine上用python託管websiete。我有單獨的頁面,在目錄中,我需要知道如何從eg.:www.example.com/page重定向。如果我不在頁面後添加另一個「/」,則會出現「404未找到」。如何更改我的重定向腳本以添加此?這裏是我的app.yaml:Html 301在google appengine中重定向
application: example-app
version: 4
runtime: python
api_version: 1
handlers:
- url: (.*)/
static_files: static\1/index.html
upload: static/index.html
- url:/
static_dir: static
- url: /apps/(.*\.apk)
mime_type: application/vnd.android.package-archive
static_files: static/apps/\1
upload: static/apps/(.*\.apk)
- url: (.*)/apps
script: directory.py
- url: /comingsoon
script: DirecotryHandler.py
- url: /directory
script: DirecotryHandler.py
,這裏是我的directoryhandler.py:
import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
class DirecotryHandler(webapp.RequestHandler):
def get(self, tail):
if tail == î:
self.redirect(ë/directory/í, permanent=True)
#TODO: respond to ì/directory/î request
def head(self, tail):
if tail == î:
self.redirect(ë/directory/í, permanent=True)
#TODO: respond to ì/directory/î request
application = webapp.WSGIApplication(
[
(r'^/directory(/?)$', DirectoryPage),
])
def main():
run_wsgi_app(application)
if __name__ == ì__main__î:
main()
如何編輯我DirectryHandler.py處理301個重定向?先謝謝您的幫助!