Re: [Cppcms-users] CppCMS-Embedded web root
Brought to you by:
artyom-beilis
From: Rodrigo E. <rod...@gm...> - 2016-02-12 04:14:24
|
I think that I need to explain better what I would like expect from the CppCms. I have a little application that I wrote in Java and have specific urls indexed by google: http://domain.com/ --> reflects the main page http://domain.com/[others-pretty-url] --> reflects each functions of the application. The application urls were indexed by google, and I don't want to lose these urls. I need to rewrite this application in C++ and I decided to use CppCms. Then I expect to use the same URLs as were indexed by Google. The main page need to responds the root url (http://domain.com/) and the other urls need respond like pretty urls (http://domain.com/some-pretty-url). I did as Artyom tells me to do. Changing the rewrite rules as below: change: { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } for this: { "regex" : "/(.*)" , "pattern" : "/mb.fcgi$1"} Immediately resolved the problem with the root url, but the rest of urls stop to work because the server takes the part after the "/" and concatenates with the /mb.fcgi. Unhappily there isn't any url with no "/" before them. I tried overcome that changing the dispatcher configuration of the url, like that: I changed this: dispatcher().assign("/contact-form",&my_app::contact_form,this); mapper().assign("contact_form","/contact-form"); For this: dispatcher().assign("contact-form",&my_app::contact_form,this); mapper().assign("contact_form","contact-form"); Unhappily this changing didn't work. Anybody has some idea how I can resolve that. Thanks 2016-02-11 20:56 GMT-02:00 Rodrigo Emygdio <rod...@gm...>: > Hi Artyom, > > Thanks very much for your feedback. I tested the virtual main method and > is executing properly. I changed the regex and the root url works very > well. The problem now is that any other url just works if I add an extra > "/" on the begin on the path. > > Thanks > > 2016-02-11 6:10 GMT-02:00 Artyom Beilis <art...@gm...>: > >> > class my_app : public cppcms::application{ >> > public: >> > my_app(cppcms::service& s) : cppcms::application(s){ >> > dispatcher().assign("",&my_app::well_come,this); >> > mapper().assign(""); >> > mapper().root(""); >> > } >> >> 1st check if cppcms::application::main is called (I think it should) >> it is virtual >> member function so you can override it. >> >> 2nd When you access to "localhost:8080" you get request GET / HTTP/1.0 >> it is mapped according to the rules to >> >> /mb.fcgi/ >> >> Than /mb.fcgi is matched and the path you get is "/" >> >> When you map to "" you Require empty path and thus it does not get >> dispatched. >> >> The correct is always to map to something starting with "/" or map to >> "/?" i.e. last "/" is optional. >> >> >> You can also use little bit different rule >> >> Instead of this >> >> { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } >> >> Use >> >> { "regex" : "/(.*)" , "pattern" : "/mb.fcgi$1" } >> >> Than none of your urls will start from "/" >> >> it does not matter how do you do it - just pic and convention and stick >> to it. >> >> Artyom >> >> >> ------------------------------------------------------------------------------ >> Site24x7 APM Insight: Get Deep Visibility into Application Performance >> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month >> Monitor end-to-end web transactions and take corrective actions now >> Troubleshoot faster and improve end-user experience. Signup Now! >> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 >> _______________________________________________ >> Cppcms-users mailing list >> Cpp...@li... >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> > > |