[Catalyst] configurable base url?
Peter Edwards
peter at dragonstaff.com
Fri Dec 7 08:12:41 GMT 2007
Presuming that the only semantic meaning of 'versionn.nn' is splitting which
handler to go to, you can do this from Apache 2 with mod_rewrite. (If you
wanted to handle the version.nn dynamically within the app you'd need to
hanle the URL processing inside your app.)
In the Apache configuration, e.g. /etc/httpd/conf.d/myspecialapp.conf
<IfModule mod_rewrite.c>
<VirtualHost *:80>
RewriteEngine On
RewriteLogLevel 0
RewriteLog /var/log/httpd/rewrite.log
RewriteRule ^/myspecialapp/version1.2/(.*$)
http://localhost:2502/$1 [P]
ProxyPassReverse /myspecialapp/version1.2/ http://localhost:2502/
RewriteRule ^/myspecialapp/version1.3/(.*$)
http://localhost:2503/$1 [P]
ProxyPassReverse /myspecialapp/version1.3/ http://localhost:2503/
RewriteRule ^proxy:.* - [F]
</VirtualHost>
</IfModule>
Then run your version 1.2 app listening at localhost port 2502 and your
version 1.3 app listening at localhost port 2503.
Apache will map incoming http://myserver/myspecialapp/version1.2/ on to
localhost:2502 and pass it path part /.
If Apache got back, say, path part /login it would return to the browser
http://myserver/myspecialapp/version1.2/login.
Regards, Peter
http://perl.dragonstaff.co.uk
On 6. des.. 2007, at 18.32, Pablo Collins wrote:
> Hi all,
>
> I some catalyst apps whose different versions I'd like to make
> available by base path, like
>
> http://mydomain/myspecialapp/version1.2/
> http://mydomain/myspecialapp/version1.3/
> etc.
>
> I was planning on using a lighttpd or apache proxy to several
> Catalyst::Engine::HTTP processes running the different versions.
> That part is straightforward.
>
> What I'm hung up on is how to tell catalyst to throw away the /
> myspecialapp/version1.3 part of the url and start the controller
> matching from there. I'd like to not have to change the names and
> namespaces of the controllers based on their versions if possible.
>
> Instead I'd like to be able to put the application root url in the
> config and have it just work.
>
> Is this possible / relatively easy to do?
>
> Thanks much.
>
> -Pablo
>
More information about the Catalyst
mailing list