mod rewrite - How to add a query string like QSA flag of mod_rewrite when using mod_lua in Apache? -


i want write script rewrite url in mod_lua, want inherit query string qsa flag of mod_rewrite.

mod_rewrite config:

rewrutecond ^/foobar/([0-9a-za-z]+)/(.+)$ rewriterule ^.*$ /foobar/$2?_id_=$1 [qsa,l] 

i try code in mod_lua below, not work well. please tell me wrong? and, able more simple code?

mod_lua config:

loadmodule lua_module modules/mod_lua.so luahooktranslatename /usr/local/httpd/conf/extra/lua/router.lua app_routing 

/usr/local/httpd/conf/extra/lua/router.lua routing:

require "apache2" function app_routing(r)   local matches = r:regex(r.uri, [[^/foobar/([0-9a-za-z]+)/(.+)$]])   if matches     r.uri  = "/foobar/" .. matches[2]     if r.args         r.args = r.args .. "&_id_=" .. matches[1]     else         r.args = "?_id_=" .. matches[1]     end   end end 

a couple of things before can solving issue:

  • r.args should never start "?", question mark not present in query string, delimiter used denote query string begins, not part of string itself.
  • you should enable debugging both mod_lua , script. try adding "loglevel lua:debug" configuration , check error log debug output. also, add debugging script using r:info(logmessage_here), spit out own debug messages in error log.

once done, we'll have error log worth checking hints.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -