Forum Moderators: phranque
/path/base_abc_def_ghi.gif
/path/base_jkl_mno_pqr.gif
Can I rewrite that to become CGI script options like this:
/CGIscriptpath/script?option=abc_def_ghi
/CGIscriptpath/script?option=jkl_mno_pqr
I would want to use the /path/base_ to trigger the rewrite and take everything after that, excluding the .gif to become the querystring's "option" value.
In my mind it seems pretty simple --- In code, I'd just extract the substring from the source URL and append it to the target URL.
I'm also wondering if a redirect has to be sent or if the source URL can just be mapped to the target internally without ReWriting? (both the source and target are local to the same HTTPd).
Or, would a simple redirect work?
Redirect /path/base_ /CGIscriptpath/script?option=
or RedirectMatch perhaps?
* can a same-server redirect target start with a "/" (a local absolute URL) or does it need to start with http:...? ie:
Redirect /path/base_ http://example.com/CGIscriptpath/script?option=
In this case, my script would then have to strip the .gif from the querystring, but that's ok.
Jim
/path/base_abc.def.ghi.gif
I create URLs like:
/path/base/abc.def.ghi.gif
in httpd.conf, I have
Redirect /path/base/ http://example.com/CGIscriptpath/script?option=
This allows what looks like a URL to actually be script input. PHP explode()s the option into different vars.
For now this is OK -- now I'll get to the rewriting action... Thanks of pointing me in the right direction.
You can use mod_rewrite to rewrite --not redirect-- the request, in order to avoid that problem.
Alternately, you could use AcceptPathInfo [httpd.apache.org] to pass parameters from the URL to your script.
Jim