Re: [Cppcms-users] RES: RES: URL maps
Brought to you by:
artyom-beilis
From: Artyom <art...@ya...> - 2011-03-26 09:13:34
|
Hello, First of all I'll try to explain. Generally your web server, apache, lighttpd, nginx and all others map some script name to the FastCGI application and serve all other static files. So for example if you have directory like /project/root /project/root/media/my.css /project/root/images/mypic.png And then to distinguish between the application and the static files so called script name is provided. So we give let's say script name "/myapp" then everything like http://server/myapp http://server/myapp/page/cool/1034 http://server/myapp/something/else Would be passed to the application, while everything else (static files) would be server by the web server, and it is very-very good in it. Now when URL like http://server/myapp/page/cool/1034 Is serverd It is divided into CGI variables: HTTP_HOST server SCRIPT_NAME /myapp PATH_INFO /page/cool/1034 Now dispatching by default works with PATH_INFO which is generally the best option. So you need to do URL mapping against it. So in this configuration. document_root is "/project/root" - local file system script is "/myapp" And you should map like "/page/.*" You can take a look as a good example the message_board in new 0.99.7 release. Now setting "/" as script is bad idea as it passes everything to the application and you don't want it as it forces you to serve static content (and you don't want to) You can make URLs like http://host/page/cool/1023 And http://host/media/my.css Work using URL rewriting provided by all modern real web servers, however such things are not supported by the internal web server which is suitable for debugging only. (Ohhh I need to add this to CppCMS's wiki as it is quite common question). So in your case it should be "http" : { "script" : "/portal", }, And matching: add(_test, "/test((/.*))?",2); // first match - from test/foo -> extracts "/foo" for // URL http://host/portal/test/foo add(_portal, "(.*)", 1); // match everything else // extracts "/bar" from "/bar for URL http://host/portal/bar Artyom ----- Original Message ---- > From: Renato Forti <re....@ay...> > To: cpp...@li... > Sent: Fri, March 25, 2011 5:56:58 PM > Subject: [Cppcms-users] RES: RES: URL maps > > Thanks for help, > > How config file should be to work? > > This is what I have: > > { > "vws" : { > "media" : "/media", > "root" : "/vws", > "host" : "localhost:8080", > "connection-string-dir" : >"E:\\project.vgsws\\resources\\connection-strings" > }, > "service" : { > "api" : "http", > "port" : 8080, > "worker_threads" : 20, > > }, > "http" : { > "script" : "/", > "script_names" : [ "/test", "/portal" ] > }, > "file_server" : { > "enable" : true > }, > "session" : { > "expire" : "renew", > "timeout" : 604800, > "location" : "client", > "client" : { > "encryptor" : "hmac", > "key" : "232074faa0fd37de20858bf8cd0a7d04" > } > }, > } > > And in class: > > class App : public cppcms::application > { > public: > > Test _test; > Portal _portal; > > App(cppcms::service &s) > : cppcms::application(s) > , _test(s) > , _portal(s) > { > add(_test, "/test", 1); > add(_portal, "/portal", 1); > } > }; > > Thank you very much, for help. > > > -----Mensagem original----- > De: Cristian Oneț [mailto:one...@gm...] > Enviada em: sexta-feira, 25 de março de 2011 12:29 > Para: cpp...@li... > Assunto: Re: [Cppcms-users] RES: URL maps > > It does not work because you application is mounted at '/' and your >sub-applications at '/test' and '/home' and that's relative to your parent >application's mountpoint. So after '/' is matched for your main application you >will only have 'test' (not '/test') or 'home' (not > '/home') left from the url to match and it will not match. > > On Fri, Mar 25, 2011 at 4:57 PM, Renato Forti <re....@ay...> wrote: > > Like this: > > > > "http" : { > > "script_names" : [ "/test", "/ home " ] > > }, > > > > :o(, I did try, but don't work... > > > > Any tip? > > > > Thanks, thanks, thanks... > > > > -----Mensagem original----- > > De: Cristian Oneț [mailto:one...@gm...] Enviada em: > > sexta-feira, 25 de março de 2011 11:53 > > Para: cpp...@li... > > Assunto: Re: [Cppcms-users] URL maps > > > > I think that your problem is that "/test" and "/home" are missing from the >scripts section of the configuration file. > > > > On Fri, Mar 25, 2011 at 3:15 PM, Renato Forti <re....@ay...> wrote: > >> Hi, > >> > >> > >> > >> I am try understand how group and map url. > >> > >> > >> > >> For sample I have 2 classes: > >> > >> > >> > >> class Home : public cppcms::application > >> > >> class Test : public cppcms::application > >> > >> > >> > >> And a class that I can group apps: > >> > >> > >> > >> class App : public cppcms::application > >> > >> { > >> > >> public: > >> > >> > >> > >> Home _home; > >> > >> Test _test; > >> > >> > >> > >> App(cppcms::service &s) > >> > >> : cppcms::application(s) > >> > >> , _home(s) > >> > >> , _test(s) > >> > >> { > >> > >> add(_test, "/test", 1); > >> > >> add(_home, "/home", 2); > >> > >> } > >> > >> }; > >> > >> > >> > >> > >> > >> > >> > >> int main(int argc,char ** argv) > >> > >> { > >> > >> try > >> > >> { > >> > >> cppcms::service srv(argc, argv); > >> > >> srv.applications_pool().mount(cppcms::applications_factory<App>()); > >> > >> srv.run(); > >> > >> } > >> > >> catch(std::exception const &e) > >> > >> { > >> > >> std::cerr<<e.what()<<std::endl; > >> > >> } > >> > >> } > >> > >> > >> > >> But when I’d tried access like: > >> > >> > >> > >> http://localhost:8080/test > >> > >> or > >> > >> http://localhost:8080/home > >> > >> > >> > >> Don’t work, What is wrong? > >> > >> > >> > >> My config file: > >> > >> > >> > >> { > >> > >> > >> > >> "service" : { > >> > >> "api" : "http", > >> > >> "port" : 8080, > >> > >> "worker_threads" : 20, > >> > >> > >> > >> }, > >> > >> "http" : { > >> > >> "script" : "/" > >> > >> }, > >> > >> "file_server" : { > >> > >> "enable" : true > >> > >> }, > >> > >> "session" : { > >> > >> "expire" : "renew", > >> > >> "timeout" : 604800, > >> > >> "location" : "client", > >> > >> "client" : { > >> > >> "encryptor" : "hmac", > >> > >> "key" : > >> "232074faa0fd37de20858bf8cd0a7d04" > >> > >> } > >> > >> }, > >> > >> } > >> > >> > >> > >> Thaks > >> > >> --------------------------------------------------------------------- > >> - > >> -------- Enable your software for Intel(R) Active Management > >> Technology to meet the growing manageability and security demands of > >> your customers. Businesses are taking advantage of Intel(R) vPro (TM) > >> technology - will your software be a part of the solution? Download > >> the Intel(R) Manageability Checker today! > >> http://p.sf.net/sfu/intel-dev2devmar > >> _______________________________________________ > >> Cppcms-users mailing list > >> Cpp...@li... > >> https://lists.sourceforge.net/lists/listinfo/cppcms-users > >> > >> > > ---------------------------------------------------------------------- > > -------- Enable your software for Intel(R) Active Management > > Technology to meet the growing manageability and security demands of > > your customers. Businesses are taking advantage of Intel(R) vPro (TM) > > technology - will your software be a part of the solution? Download > > the Intel(R) Manageability Checker today! > > http://p.sf.net/sfu/intel-dev2devmar > > _______________________________________________ > > Cppcms-users mailing list > > Cpp...@li... > > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > > > ---------------------------------------------------------------------- > > -------- Enable your software for Intel(R) Active Management > > Technology to meet the growing manageability and security demands of > > your customers. Businesses are taking advantage of Intel(R) vPro (TM) > > technology - will your software be a part of the solution? Download > > the Intel(R) Manageability Checker today! > > http://p.sf.net/sfu/intel-dev2devmar > > _______________________________________________ > > Cppcms-users mailing list > > Cpp...@li... > > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > ------------------------------------------------------------------------------ > Enable your software for Intel(R) Active Management Technology to meet the >growing manageability and security demands of your customers. Businesses are >taking advantage of Intel(R) vPro (TM) technology - will your software be a >part of the solution? Download the Intel(R) Manageability Checker today! >http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > ------------------------------------------------------------------------------ > Enable your software for Intel(R) Active Management Technology to meet the > growing manageability and security demands of your customers. Businesses > are taking advantage of Intel(R) vPro (TM) technology - will your software > be a part of the solution? Download the Intel(R) Manageability Checker > today! http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |