How can I 301 redirect a page URL on Google App Engine?












1















I am updating the file structure of my hand coded static site, as I originally created it a while back when I had less of an appreciation of best practices for file structure in web development.



I am aware that for best user experience, as well as optimal SEO purposes, redirects should be used minimally.



I have searched Stack Overflow and Google in general for a solution for setting up 301 redirects for individual static page URL's on Google App Engine (GAE), however I only seem to be able to find entire domain name redirect explinations.



The site is hand coded in html, css and js with Bootstrap v3.3.7 integrated for mobile responsiveness.



The site is hosted on Google App Engine and is a subdomain of .appspot.com (http://christopher-john-roberts.appspot.com).



I will be for example moving the following page:



http://christopher-john-roberts.appspot.com/content/scientific-skills/mres-post-genomic-science.html



to the new URL:



http://christopher-john-roberts.appspot.com/scientific-skills/mres-post-genomic-science.html



still under http://christopher-john-roberts.appspot.com/



My app.yaml is as follows:



 runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /
static_files: www/index.html
upload: www/index.html

- url: /(.*)
static_files: www/1
upload: www/(.*)


My main.py file is as follows:



import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template

class MainHandler(webapp.RequestHandler):
def get (self, q):
if q is None:
q = 'index.html'

path = os.path.join (os.path.dirname (__file__), q)
self.response.headers ['Content-Type'] = 'text/html'
self.response.out.write (template.render (path, {}))

def main ():
application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
util.run_wsgi_app (application)

if __name__ == '__main__':
main ()


If scripting is required I would prefer to implement a python solution as that is the current deployment on GAE.



Don't hesitate to ask if I have missed out any vital information.



Thanks in advance for your response.





UPDATE



I have now tried editing my main.py file to introduce a self.redirect as follows:



import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template

class MainHandler(webapp.RequestHandler):
def get (self, q):
if q is None:
q = 'index.html'

if q = 'content/scientific-skills/mres-post-genomic-science.html':
redirect_url = 'http://christopher-john-roberts.appspot.com/scientific-skills/mres-post-genomic-science.html'
self.redirect(redirect_url, permanent=True)

path = os.path.join (os.path.dirname (__file__), q)
self.response.headers ['Content-Type'] = 'text/html'
self.response.out.write (template.render (path, {}))

def main ():
application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
util.run_wsgi_app (application)

if __name__ == '__main__':
main ()


However this did not work. When visiting the url http://www.christopher-john-roberts.appspot.com/content/scientific-skills/mres-post-genomic-science.html I am not redirected and instead get Error: Not Found
The requested URL /content/scientific-skills/mres-post-genomic-science.html was not found on this server.



I have also tried:



import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template

class MainHandler(webapp.RequestHandler):
def get (self, q):
if q is None:
q = 'index.html'

path = os.path.join (os.path.dirname (__file__), q)
self.response.headers ['Content-Type'] = 'text/html'
self.response.out.write (template.render (path, {}))

if q = 'content/scientific-skills/mres-post-genomic-science.html':
redirect_url = 'http://christopher-john-roberts.appspot.com/scientific-skills/mres-post-genomic-science.html'
self.redirect(redirect_url, permanent=True)

def main ():
application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
util.run_wsgi_app (application)

if __name__ == '__main__':
main ()


As well as ...



import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template

class MainHandler(webapp.RequestHandler):
def get (self, q):
if q is None:
q = 'index.html'

if q = 'content/scientific-skills/mres-post-genomic-science.html':
redirect_url = 'scientific-skills/mres-post-genomic-science.html'
self.redirect(redirect_url, permanent=True)

path = os.path.join (os.path.dirname (__file__), q)
self.response.headers ['Content-Type'] = 'text/html'
self.response.out.write (template.render (path, {}))

def main ():
application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
util.run_wsgi_app (application)

if __name__ == '__main__':
main ()




UPDATE 2



I have provided a screenshot below of my current main.py file:



screenshot of main.py file





UPDATE 3



My latest main.py file:



latest screenshot of main.py



The logs:



screenshot of logs










share|improve this question





























    1















    I am updating the file structure of my hand coded static site, as I originally created it a while back when I had less of an appreciation of best practices for file structure in web development.



    I am aware that for best user experience, as well as optimal SEO purposes, redirects should be used minimally.



    I have searched Stack Overflow and Google in general for a solution for setting up 301 redirects for individual static page URL's on Google App Engine (GAE), however I only seem to be able to find entire domain name redirect explinations.



    The site is hand coded in html, css and js with Bootstrap v3.3.7 integrated for mobile responsiveness.



    The site is hosted on Google App Engine and is a subdomain of .appspot.com (http://christopher-john-roberts.appspot.com).



    I will be for example moving the following page:



    http://christopher-john-roberts.appspot.com/content/scientific-skills/mres-post-genomic-science.html



    to the new URL:



    http://christopher-john-roberts.appspot.com/scientific-skills/mres-post-genomic-science.html



    still under http://christopher-john-roberts.appspot.com/



    My app.yaml is as follows:



     runtime: python27
    api_version: 1
    threadsafe: true

    handlers:
    - url: /
    static_files: www/index.html
    upload: www/index.html

    - url: /(.*)
    static_files: www/1
    upload: www/(.*)


    My main.py file is as follows:



    import os
    from google.appengine.ext import webapp
    from google.appengine.ext.webapp import util
    from google.appengine.ext.webapp import template

    class MainHandler(webapp.RequestHandler):
    def get (self, q):
    if q is None:
    q = 'index.html'

    path = os.path.join (os.path.dirname (__file__), q)
    self.response.headers ['Content-Type'] = 'text/html'
    self.response.out.write (template.render (path, {}))

    def main ():
    application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
    util.run_wsgi_app (application)

    if __name__ == '__main__':
    main ()


    If scripting is required I would prefer to implement a python solution as that is the current deployment on GAE.



    Don't hesitate to ask if I have missed out any vital information.



    Thanks in advance for your response.





    UPDATE



    I have now tried editing my main.py file to introduce a self.redirect as follows:



    import os
    from google.appengine.ext import webapp
    from google.appengine.ext.webapp import util
    from google.appengine.ext.webapp import template

    class MainHandler(webapp.RequestHandler):
    def get (self, q):
    if q is None:
    q = 'index.html'

    if q = 'content/scientific-skills/mres-post-genomic-science.html':
    redirect_url = 'http://christopher-john-roberts.appspot.com/scientific-skills/mres-post-genomic-science.html'
    self.redirect(redirect_url, permanent=True)

    path = os.path.join (os.path.dirname (__file__), q)
    self.response.headers ['Content-Type'] = 'text/html'
    self.response.out.write (template.render (path, {}))

    def main ():
    application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
    util.run_wsgi_app (application)

    if __name__ == '__main__':
    main ()


    However this did not work. When visiting the url http://www.christopher-john-roberts.appspot.com/content/scientific-skills/mres-post-genomic-science.html I am not redirected and instead get Error: Not Found
    The requested URL /content/scientific-skills/mres-post-genomic-science.html was not found on this server.



    I have also tried:



    import os
    from google.appengine.ext import webapp
    from google.appengine.ext.webapp import util
    from google.appengine.ext.webapp import template

    class MainHandler(webapp.RequestHandler):
    def get (self, q):
    if q is None:
    q = 'index.html'

    path = os.path.join (os.path.dirname (__file__), q)
    self.response.headers ['Content-Type'] = 'text/html'
    self.response.out.write (template.render (path, {}))

    if q = 'content/scientific-skills/mres-post-genomic-science.html':
    redirect_url = 'http://christopher-john-roberts.appspot.com/scientific-skills/mres-post-genomic-science.html'
    self.redirect(redirect_url, permanent=True)

    def main ():
    application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
    util.run_wsgi_app (application)

    if __name__ == '__main__':
    main ()


    As well as ...



    import os
    from google.appengine.ext import webapp
    from google.appengine.ext.webapp import util
    from google.appengine.ext.webapp import template

    class MainHandler(webapp.RequestHandler):
    def get (self, q):
    if q is None:
    q = 'index.html'

    if q = 'content/scientific-skills/mres-post-genomic-science.html':
    redirect_url = 'scientific-skills/mres-post-genomic-science.html'
    self.redirect(redirect_url, permanent=True)

    path = os.path.join (os.path.dirname (__file__), q)
    self.response.headers ['Content-Type'] = 'text/html'
    self.response.out.write (template.render (path, {}))

    def main ():
    application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
    util.run_wsgi_app (application)

    if __name__ == '__main__':
    main ()




    UPDATE 2



    I have provided a screenshot below of my current main.py file:



    screenshot of main.py file





    UPDATE 3



    My latest main.py file:



    latest screenshot of main.py



    The logs:



    screenshot of logs










    share|improve this question



























      1












      1








      1








      I am updating the file structure of my hand coded static site, as I originally created it a while back when I had less of an appreciation of best practices for file structure in web development.



      I am aware that for best user experience, as well as optimal SEO purposes, redirects should be used minimally.



      I have searched Stack Overflow and Google in general for a solution for setting up 301 redirects for individual static page URL's on Google App Engine (GAE), however I only seem to be able to find entire domain name redirect explinations.



      The site is hand coded in html, css and js with Bootstrap v3.3.7 integrated for mobile responsiveness.



      The site is hosted on Google App Engine and is a subdomain of .appspot.com (http://christopher-john-roberts.appspot.com).



      I will be for example moving the following page:



      http://christopher-john-roberts.appspot.com/content/scientific-skills/mres-post-genomic-science.html



      to the new URL:



      http://christopher-john-roberts.appspot.com/scientific-skills/mres-post-genomic-science.html



      still under http://christopher-john-roberts.appspot.com/



      My app.yaml is as follows:



       runtime: python27
      api_version: 1
      threadsafe: true

      handlers:
      - url: /
      static_files: www/index.html
      upload: www/index.html

      - url: /(.*)
      static_files: www/1
      upload: www/(.*)


      My main.py file is as follows:



      import os
      from google.appengine.ext import webapp
      from google.appengine.ext.webapp import util
      from google.appengine.ext.webapp import template

      class MainHandler(webapp.RequestHandler):
      def get (self, q):
      if q is None:
      q = 'index.html'

      path = os.path.join (os.path.dirname (__file__), q)
      self.response.headers ['Content-Type'] = 'text/html'
      self.response.out.write (template.render (path, {}))

      def main ():
      application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
      util.run_wsgi_app (application)

      if __name__ == '__main__':
      main ()


      If scripting is required I would prefer to implement a python solution as that is the current deployment on GAE.



      Don't hesitate to ask if I have missed out any vital information.



      Thanks in advance for your response.





      UPDATE



      I have now tried editing my main.py file to introduce a self.redirect as follows:



      import os
      from google.appengine.ext import webapp
      from google.appengine.ext.webapp import util
      from google.appengine.ext.webapp import template

      class MainHandler(webapp.RequestHandler):
      def get (self, q):
      if q is None:
      q = 'index.html'

      if q = 'content/scientific-skills/mres-post-genomic-science.html':
      redirect_url = 'http://christopher-john-roberts.appspot.com/scientific-skills/mres-post-genomic-science.html'
      self.redirect(redirect_url, permanent=True)

      path = os.path.join (os.path.dirname (__file__), q)
      self.response.headers ['Content-Type'] = 'text/html'
      self.response.out.write (template.render (path, {}))

      def main ():
      application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
      util.run_wsgi_app (application)

      if __name__ == '__main__':
      main ()


      However this did not work. When visiting the url http://www.christopher-john-roberts.appspot.com/content/scientific-skills/mres-post-genomic-science.html I am not redirected and instead get Error: Not Found
      The requested URL /content/scientific-skills/mres-post-genomic-science.html was not found on this server.



      I have also tried:



      import os
      from google.appengine.ext import webapp
      from google.appengine.ext.webapp import util
      from google.appengine.ext.webapp import template

      class MainHandler(webapp.RequestHandler):
      def get (self, q):
      if q is None:
      q = 'index.html'

      path = os.path.join (os.path.dirname (__file__), q)
      self.response.headers ['Content-Type'] = 'text/html'
      self.response.out.write (template.render (path, {}))

      if q = 'content/scientific-skills/mres-post-genomic-science.html':
      redirect_url = 'http://christopher-john-roberts.appspot.com/scientific-skills/mres-post-genomic-science.html'
      self.redirect(redirect_url, permanent=True)

      def main ():
      application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
      util.run_wsgi_app (application)

      if __name__ == '__main__':
      main ()


      As well as ...



      import os
      from google.appengine.ext import webapp
      from google.appengine.ext.webapp import util
      from google.appengine.ext.webapp import template

      class MainHandler(webapp.RequestHandler):
      def get (self, q):
      if q is None:
      q = 'index.html'

      if q = 'content/scientific-skills/mres-post-genomic-science.html':
      redirect_url = 'scientific-skills/mres-post-genomic-science.html'
      self.redirect(redirect_url, permanent=True)

      path = os.path.join (os.path.dirname (__file__), q)
      self.response.headers ['Content-Type'] = 'text/html'
      self.response.out.write (template.render (path, {}))

      def main ():
      application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
      util.run_wsgi_app (application)

      if __name__ == '__main__':
      main ()




      UPDATE 2



      I have provided a screenshot below of my current main.py file:



      screenshot of main.py file





      UPDATE 3



      My latest main.py file:



      latest screenshot of main.py



      The logs:



      screenshot of logs










      share|improve this question
















      I am updating the file structure of my hand coded static site, as I originally created it a while back when I had less of an appreciation of best practices for file structure in web development.



      I am aware that for best user experience, as well as optimal SEO purposes, redirects should be used minimally.



      I have searched Stack Overflow and Google in general for a solution for setting up 301 redirects for individual static page URL's on Google App Engine (GAE), however I only seem to be able to find entire domain name redirect explinations.



      The site is hand coded in html, css and js with Bootstrap v3.3.7 integrated for mobile responsiveness.



      The site is hosted on Google App Engine and is a subdomain of .appspot.com (http://christopher-john-roberts.appspot.com).



      I will be for example moving the following page:



      http://christopher-john-roberts.appspot.com/content/scientific-skills/mres-post-genomic-science.html



      to the new URL:



      http://christopher-john-roberts.appspot.com/scientific-skills/mres-post-genomic-science.html



      still under http://christopher-john-roberts.appspot.com/



      My app.yaml is as follows:



       runtime: python27
      api_version: 1
      threadsafe: true

      handlers:
      - url: /
      static_files: www/index.html
      upload: www/index.html

      - url: /(.*)
      static_files: www/1
      upload: www/(.*)


      My main.py file is as follows:



      import os
      from google.appengine.ext import webapp
      from google.appengine.ext.webapp import util
      from google.appengine.ext.webapp import template

      class MainHandler(webapp.RequestHandler):
      def get (self, q):
      if q is None:
      q = 'index.html'

      path = os.path.join (os.path.dirname (__file__), q)
      self.response.headers ['Content-Type'] = 'text/html'
      self.response.out.write (template.render (path, {}))

      def main ():
      application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
      util.run_wsgi_app (application)

      if __name__ == '__main__':
      main ()


      If scripting is required I would prefer to implement a python solution as that is the current deployment on GAE.



      Don't hesitate to ask if I have missed out any vital information.



      Thanks in advance for your response.





      UPDATE



      I have now tried editing my main.py file to introduce a self.redirect as follows:



      import os
      from google.appengine.ext import webapp
      from google.appengine.ext.webapp import util
      from google.appengine.ext.webapp import template

      class MainHandler(webapp.RequestHandler):
      def get (self, q):
      if q is None:
      q = 'index.html'

      if q = 'content/scientific-skills/mres-post-genomic-science.html':
      redirect_url = 'http://christopher-john-roberts.appspot.com/scientific-skills/mres-post-genomic-science.html'
      self.redirect(redirect_url, permanent=True)

      path = os.path.join (os.path.dirname (__file__), q)
      self.response.headers ['Content-Type'] = 'text/html'
      self.response.out.write (template.render (path, {}))

      def main ():
      application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
      util.run_wsgi_app (application)

      if __name__ == '__main__':
      main ()


      However this did not work. When visiting the url http://www.christopher-john-roberts.appspot.com/content/scientific-skills/mres-post-genomic-science.html I am not redirected and instead get Error: Not Found
      The requested URL /content/scientific-skills/mres-post-genomic-science.html was not found on this server.



      I have also tried:



      import os
      from google.appengine.ext import webapp
      from google.appengine.ext.webapp import util
      from google.appengine.ext.webapp import template

      class MainHandler(webapp.RequestHandler):
      def get (self, q):
      if q is None:
      q = 'index.html'

      path = os.path.join (os.path.dirname (__file__), q)
      self.response.headers ['Content-Type'] = 'text/html'
      self.response.out.write (template.render (path, {}))

      if q = 'content/scientific-skills/mres-post-genomic-science.html':
      redirect_url = 'http://christopher-john-roberts.appspot.com/scientific-skills/mres-post-genomic-science.html'
      self.redirect(redirect_url, permanent=True)

      def main ():
      application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
      util.run_wsgi_app (application)

      if __name__ == '__main__':
      main ()


      As well as ...



      import os
      from google.appengine.ext import webapp
      from google.appengine.ext.webapp import util
      from google.appengine.ext.webapp import template

      class MainHandler(webapp.RequestHandler):
      def get (self, q):
      if q is None:
      q = 'index.html'

      if q = 'content/scientific-skills/mres-post-genomic-science.html':
      redirect_url = 'scientific-skills/mres-post-genomic-science.html'
      self.redirect(redirect_url, permanent=True)

      path = os.path.join (os.path.dirname (__file__), q)
      self.response.headers ['Content-Type'] = 'text/html'
      self.response.out.write (template.render (path, {}))

      def main ():
      application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
      util.run_wsgi_app (application)

      if __name__ == '__main__':
      main ()




      UPDATE 2



      I have provided a screenshot below of my current main.py file:



      screenshot of main.py file





      UPDATE 3



      My latest main.py file:



      latest screenshot of main.py



      The logs:



      screenshot of logs







      google-app-engine redirect url-redirection google-app-engine-python






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 '18 at 23:09







      Chris_Roberts

















      asked Aug 26 '18 at 21:35









      Chris_RobertsChris_Roberts

      63




      63
























          1 Answer
          1






          active

          oldest

          votes


















          1














          There is a self.redirect built right into webapp. Add this to your def get(self, q):



          logging.info(q)

          if q == 'content/scientific-skills/mres-post-genomic-science.html':

          redirect_url = 'http://christopher-john-roberts.appspot.com/scientific-skills/mres-post-genomic-science.html'

          self.redirect(redirect_url, permanent=True)





          share|improve this answer


























          • Sorry about the late response. I have tried this for a number of hours with no success. As a test I have moved the page to christopher-john-roberts.appspot.com/scientific-skills/… which works, but when you type in christopher-john-roberts.appspot.com/content/scientific-skills/… you are not redirected to the first url. I have updated with original question above with variations I have tried.

            – Chris_Roberts
            Nov 21 '18 at 12:28








          • 1





            That should be a double equals sign == in if q == 'content/scientific-skills/mres-post-genomic-science.html': Log q to see what its current value is at that url.

            – GAEfan
            Nov 22 '18 at 1:19











          • I should have mentioned that I had also tried with the double equals sign after I commented. The live version now has if q == 'content/scientific-skills/mres-post-genomic-science.html': however it is still not working. I am unsure how to "Log q to see what its current value is at that url". I am only used to logging in JavaScript. I have added import logging after import os and added logging.warning(q) after self.redirect(redirect_url, permanent=True) but I don't see anything.

            – Chris_Roberts
            Nov 22 '18 at 12:56











          • I have provided a screenshot of the main.py file at the bottom of the above question in an update

            – Chris_Roberts
            Nov 22 '18 at 13:11











          • The logging needs to be outside the conditional. Else, you already know what it is. See update. Check your logs at: console.cloud.google.com/logs/…

            – GAEfan
            Nov 22 '18 at 17:44













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52030431%2fhow-can-i-301-redirect-a-page-url-on-google-app-engine%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          There is a self.redirect built right into webapp. Add this to your def get(self, q):



          logging.info(q)

          if q == 'content/scientific-skills/mres-post-genomic-science.html':

          redirect_url = 'http://christopher-john-roberts.appspot.com/scientific-skills/mres-post-genomic-science.html'

          self.redirect(redirect_url, permanent=True)





          share|improve this answer


























          • Sorry about the late response. I have tried this for a number of hours with no success. As a test I have moved the page to christopher-john-roberts.appspot.com/scientific-skills/… which works, but when you type in christopher-john-roberts.appspot.com/content/scientific-skills/… you are not redirected to the first url. I have updated with original question above with variations I have tried.

            – Chris_Roberts
            Nov 21 '18 at 12:28








          • 1





            That should be a double equals sign == in if q == 'content/scientific-skills/mres-post-genomic-science.html': Log q to see what its current value is at that url.

            – GAEfan
            Nov 22 '18 at 1:19











          • I should have mentioned that I had also tried with the double equals sign after I commented. The live version now has if q == 'content/scientific-skills/mres-post-genomic-science.html': however it is still not working. I am unsure how to "Log q to see what its current value is at that url". I am only used to logging in JavaScript. I have added import logging after import os and added logging.warning(q) after self.redirect(redirect_url, permanent=True) but I don't see anything.

            – Chris_Roberts
            Nov 22 '18 at 12:56











          • I have provided a screenshot of the main.py file at the bottom of the above question in an update

            – Chris_Roberts
            Nov 22 '18 at 13:11











          • The logging needs to be outside the conditional. Else, you already know what it is. See update. Check your logs at: console.cloud.google.com/logs/…

            – GAEfan
            Nov 22 '18 at 17:44


















          1














          There is a self.redirect built right into webapp. Add this to your def get(self, q):



          logging.info(q)

          if q == 'content/scientific-skills/mres-post-genomic-science.html':

          redirect_url = 'http://christopher-john-roberts.appspot.com/scientific-skills/mres-post-genomic-science.html'

          self.redirect(redirect_url, permanent=True)





          share|improve this answer


























          • Sorry about the late response. I have tried this for a number of hours with no success. As a test I have moved the page to christopher-john-roberts.appspot.com/scientific-skills/… which works, but when you type in christopher-john-roberts.appspot.com/content/scientific-skills/… you are not redirected to the first url. I have updated with original question above with variations I have tried.

            – Chris_Roberts
            Nov 21 '18 at 12:28








          • 1





            That should be a double equals sign == in if q == 'content/scientific-skills/mres-post-genomic-science.html': Log q to see what its current value is at that url.

            – GAEfan
            Nov 22 '18 at 1:19











          • I should have mentioned that I had also tried with the double equals sign after I commented. The live version now has if q == 'content/scientific-skills/mres-post-genomic-science.html': however it is still not working. I am unsure how to "Log q to see what its current value is at that url". I am only used to logging in JavaScript. I have added import logging after import os and added logging.warning(q) after self.redirect(redirect_url, permanent=True) but I don't see anything.

            – Chris_Roberts
            Nov 22 '18 at 12:56











          • I have provided a screenshot of the main.py file at the bottom of the above question in an update

            – Chris_Roberts
            Nov 22 '18 at 13:11











          • The logging needs to be outside the conditional. Else, you already know what it is. See update. Check your logs at: console.cloud.google.com/logs/…

            – GAEfan
            Nov 22 '18 at 17:44
















          1












          1








          1







          There is a self.redirect built right into webapp. Add this to your def get(self, q):



          logging.info(q)

          if q == 'content/scientific-skills/mres-post-genomic-science.html':

          redirect_url = 'http://christopher-john-roberts.appspot.com/scientific-skills/mres-post-genomic-science.html'

          self.redirect(redirect_url, permanent=True)





          share|improve this answer















          There is a self.redirect built right into webapp. Add this to your def get(self, q):



          logging.info(q)

          if q == 'content/scientific-skills/mres-post-genomic-science.html':

          redirect_url = 'http://christopher-john-roberts.appspot.com/scientific-skills/mres-post-genomic-science.html'

          self.redirect(redirect_url, permanent=True)






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 22 '18 at 17:45

























          answered Aug 27 '18 at 4:23









          GAEfanGAEfan

          6,8022823




          6,8022823













          • Sorry about the late response. I have tried this for a number of hours with no success. As a test I have moved the page to christopher-john-roberts.appspot.com/scientific-skills/… which works, but when you type in christopher-john-roberts.appspot.com/content/scientific-skills/… you are not redirected to the first url. I have updated with original question above with variations I have tried.

            – Chris_Roberts
            Nov 21 '18 at 12:28








          • 1





            That should be a double equals sign == in if q == 'content/scientific-skills/mres-post-genomic-science.html': Log q to see what its current value is at that url.

            – GAEfan
            Nov 22 '18 at 1:19











          • I should have mentioned that I had also tried with the double equals sign after I commented. The live version now has if q == 'content/scientific-skills/mres-post-genomic-science.html': however it is still not working. I am unsure how to "Log q to see what its current value is at that url". I am only used to logging in JavaScript. I have added import logging after import os and added logging.warning(q) after self.redirect(redirect_url, permanent=True) but I don't see anything.

            – Chris_Roberts
            Nov 22 '18 at 12:56











          • I have provided a screenshot of the main.py file at the bottom of the above question in an update

            – Chris_Roberts
            Nov 22 '18 at 13:11











          • The logging needs to be outside the conditional. Else, you already know what it is. See update. Check your logs at: console.cloud.google.com/logs/…

            – GAEfan
            Nov 22 '18 at 17:44





















          • Sorry about the late response. I have tried this for a number of hours with no success. As a test I have moved the page to christopher-john-roberts.appspot.com/scientific-skills/… which works, but when you type in christopher-john-roberts.appspot.com/content/scientific-skills/… you are not redirected to the first url. I have updated with original question above with variations I have tried.

            – Chris_Roberts
            Nov 21 '18 at 12:28








          • 1





            That should be a double equals sign == in if q == 'content/scientific-skills/mres-post-genomic-science.html': Log q to see what its current value is at that url.

            – GAEfan
            Nov 22 '18 at 1:19











          • I should have mentioned that I had also tried with the double equals sign after I commented. The live version now has if q == 'content/scientific-skills/mres-post-genomic-science.html': however it is still not working. I am unsure how to "Log q to see what its current value is at that url". I am only used to logging in JavaScript. I have added import logging after import os and added logging.warning(q) after self.redirect(redirect_url, permanent=True) but I don't see anything.

            – Chris_Roberts
            Nov 22 '18 at 12:56











          • I have provided a screenshot of the main.py file at the bottom of the above question in an update

            – Chris_Roberts
            Nov 22 '18 at 13:11











          • The logging needs to be outside the conditional. Else, you already know what it is. See update. Check your logs at: console.cloud.google.com/logs/…

            – GAEfan
            Nov 22 '18 at 17:44



















          Sorry about the late response. I have tried this for a number of hours with no success. As a test I have moved the page to christopher-john-roberts.appspot.com/scientific-skills/… which works, but when you type in christopher-john-roberts.appspot.com/content/scientific-skills/… you are not redirected to the first url. I have updated with original question above with variations I have tried.

          – Chris_Roberts
          Nov 21 '18 at 12:28







          Sorry about the late response. I have tried this for a number of hours with no success. As a test I have moved the page to christopher-john-roberts.appspot.com/scientific-skills/… which works, but when you type in christopher-john-roberts.appspot.com/content/scientific-skills/… you are not redirected to the first url. I have updated with original question above with variations I have tried.

          – Chris_Roberts
          Nov 21 '18 at 12:28






          1




          1





          That should be a double equals sign == in if q == 'content/scientific-skills/mres-post-genomic-science.html': Log q to see what its current value is at that url.

          – GAEfan
          Nov 22 '18 at 1:19





          That should be a double equals sign == in if q == 'content/scientific-skills/mres-post-genomic-science.html': Log q to see what its current value is at that url.

          – GAEfan
          Nov 22 '18 at 1:19













          I should have mentioned that I had also tried with the double equals sign after I commented. The live version now has if q == 'content/scientific-skills/mres-post-genomic-science.html': however it is still not working. I am unsure how to "Log q to see what its current value is at that url". I am only used to logging in JavaScript. I have added import logging after import os and added logging.warning(q) after self.redirect(redirect_url, permanent=True) but I don't see anything.

          – Chris_Roberts
          Nov 22 '18 at 12:56





          I should have mentioned that I had also tried with the double equals sign after I commented. The live version now has if q == 'content/scientific-skills/mres-post-genomic-science.html': however it is still not working. I am unsure how to "Log q to see what its current value is at that url". I am only used to logging in JavaScript. I have added import logging after import os and added logging.warning(q) after self.redirect(redirect_url, permanent=True) but I don't see anything.

          – Chris_Roberts
          Nov 22 '18 at 12:56













          I have provided a screenshot of the main.py file at the bottom of the above question in an update

          – Chris_Roberts
          Nov 22 '18 at 13:11





          I have provided a screenshot of the main.py file at the bottom of the above question in an update

          – Chris_Roberts
          Nov 22 '18 at 13:11













          The logging needs to be outside the conditional. Else, you already know what it is. See update. Check your logs at: console.cloud.google.com/logs/…

          – GAEfan
          Nov 22 '18 at 17:44







          The logging needs to be outside the conditional. Else, you already know what it is. See update. Check your logs at: console.cloud.google.com/logs/…

          – GAEfan
          Nov 22 '18 at 17:44




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52030431%2fhow-can-i-301-redirect-a-page-url-on-google-app-engine%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Tonle Sap (See)

          I get strange results when I access the Sqlitedatabase with Unity C# via XAMPP

          Guatemaltekische Davis-Cup-Mannschaft