Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Version 5 and Version 6 of RedirectHttpsRequests


Ignore:
Timestamp:
06/22/06 14:07:06 (11 years ago)
Author:
plewis
Comment:

update config to new config version, fixed typos, clarified usage of different methods

Legend:

Unmodified
Added
Removed
Modified
  • RedirectHttpsRequests

    v5 v6  
    4040''httpsfilter.py'' 
    4141{{{ 
     42#!python 
    4243from cherrypy.filters.basefilter import BaseFilter 
    4344import cherrypy 
     
    8182 
    8283{{{ 
     84#!python 
    8385from httpsfilter import HTTPSFilter 
    8486 
     
    9698 
    9799{{{ 
    98     @turbogears.expose() 
    99     def test_redirect(self): 
    100         turbogears.controllers.redirect("/") #redirect uses cherrypy.HTTPSRedirect 
     100#!python 
     101@turbogears.expose() 
     102def test_redirect(self): 
     103    turbogears.controllers.redirect("/") #redirect uses cherrypy.HTTPRedirect 
    101104}}} 
    102105 
     
    105108== Better Solutions == 
    106109 
    107 In the long run, it would be better if !CherryPy were able to listen on two different ports for requests.  If we could configure the ports to have different base urls, it would make processing redirects much easier.  It looks like this may be possible to do in upcoming versions of TurboGears. 
     110In the long run, it would be better if !CherryPy were able to listen on two different ports for requests.  If we could configure the ports to have different base urls, it would make processing redirects much easier.  It looks like this may be possible to do in upcoming versions of !TurboGears. 
    108111 
    109112= Solving the problem with Apache = 
     113 
     114The above solution will work for any protocol/url combination. For example, if you have a controller 'do_stuff' that redirects to 'done', the following will work: 
     115 
     116 * !http://example.com/do_stuff -> redirects to -> !http://example.com/done 
     117 * !https://example.com/do_stuff -> redirects to -> !https://example.com/done 
     118 
     119However, you may not need to do this in all cases.  If part of your site is only going to be accessed via https (e.g. !https://example.com/secure), you may be able to have configre Apache to fix the redirected urls to this area. 
    110120 
    111121Using Apache you configure it normally to listen on whatever port you'd like to have it.  And code your !TurboGears code normally, as if it was all local.  Using any of cherrypy.!HTTPRedirect or turbogears.redirect work the same way.