htaccess rewriterule in combination with POST form

B

Bart van den Burg

Hi

I´m currently building a new page, and instead of
http://.../page.pl?param1=val1&param2=val2
I'm using
http://.../page/val1/val2

then in .htaccess:
RewriteEngine On
RewriteRule ^page/(\d+)/(\d+)$ site.pl?page=page&param1=$1&param2=$2

This works perfectly fine. in my script i can access the parameters using
the param() function.

The problem however is, when i have a form like this:
<form action="page/val1/val2" method="post">
<input type="text" name="param3" value="val3"/>
<input type="submit" value="go!"/>
</form>

i can't access param1 and param2 from my script anymore!

Long story for a short question: What can I do, so that i can access those
parameters again, but still making the form method="post"?


(I'm not really sure whether this is due to Perl or not, but i hope you know
the answer...)
 
A

Alan J. Flavell

I´m currently building a new page, and instead of
http://.../page.pl?param1=val1&param2=val2
I'm using
http://.../page/val1/val2

You don't seem to have a Perl problem...
then in .htaccess:
RewriteEngine On
RewriteRule ^page/(\d+)/(\d+)$ site.pl?page=page&param1=$1&param2=$2

This works perfectly fine.

(except that you've now turned a static path component into a query
string, and baffled all the caches and indexing robots from here to
W3C.)

So: very interesting... but what are you trying to achieve?
in my script i can access the parameters using
the param() function.

I think we've already grasped that this is a "stealth CGI" question,
as the c.l.p.m-ers are accustomed to call it.
The problem however is, when i have a form like this:
<form action="page/val1/val2" method="post">
<input type="text" name="param3" value="val3"/>
<input type="submit" value="go!"/>
</form>

i can't access param1 and param2 from my script anymore!

method=post is different. I'd have to recommend reading its
documentation and/or following a CGI.pm tutorial, depending on whether
you're interested in the technical detail, or trying to get something
running in production, respectively.
Long story for a short question: What can I do, so that i can access
those parameters again, but still making the form method="post"?

On the basis of what you're posting (this is all that we have to go on
in usenet discussions, you understand - nothing personal - and I'm
sure you're kind to animals and small children and all that), I'd have
to suggest that you a) study the CGI interface in a bit more detail,
in particular the difference between GET and POST requests, 2) try to
make a habit of putting some context around your questions so we can
see how they are meant to fit in, and 3) raise CGI-specific questions
on comp.infosystems.www.authoring.cgi (beware the automoderation bot),
and try to limit postings on this group to issues which really relate
to the Perl language.
(I'm not really sure whether this is due to Perl or not, but i hope
you know the answer...)

I'd be happier to offer it in the right place. But frankly (and again
I stress this is nothing personal), once you understand the principles
of this part of the protocol, the answer should seem self-evident.
Until you understand this part of the HTTP protocol, I don't see how
/any/ answer could make sense. But none of that is specific to the
Perl programming language - which really puts it off-topic here.

best I can do at this time of night...
 
T

Tad McClellan

Bart van den Burg said:
Hi

I´m currently building a new page, and instead of
http://.../page.pl?param1=val1&param2=val2
I'm using
http://.../page/val1/val2

then in .htaccess:
RewriteEngine On
RewriteRule ^page/(\d+)/(\d+)$ site.pl?page=page&param1=$1&param2=$2


that puts the parameters in the URL, as with a GET request.

The problem however is, when i have a form like this:
<form action="page/val1/val2" method="post">

i can't access param1 and param2 from my script anymore!


Right.

Because a POST request wants the parameters put somewhere else.

Long story for a short question: What can I do, so that i can access those
parameters again, but still making the form method="post"?


I dunno how to do it in htaccess, but you wouldn't expect someone
in the Perl newsgroup to know that anyway.

You might expect someone to know that in a newsgroup that is
somehow related to web stuff, such as:

comp.infosystems.www.authoring.cgi
comp.infosystems.www.servers.mac
comp.infosystems.www.servers.misc
comp.infosystems.www.servers.ms-windows
comp.infosystems.www.servers.unix

(I'm not really sure whether this is due to Perl or not,


If you had chosen to use Python or Visual Basic instead of
Perl, you would have had the same problem with the setup
you describe above.

So, the "or not" part of your statement was correct. :)

but i hope you know
the answer...)


Be very very careful doing that.

Knowingly making off-topic postings can use up all of your
coupons rather quickly.

Let's count this thread as "unknowingly". :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top