Forms will show type of programming language unless..

Fix it!!

Forms will show type of programming language unless..

Postby malmklang » Mon Mar 12, 2007 6:59 am

Unless you have a solution for me :)
Hi btw!

Here's my problem right now:
I been up and down on the web, trying to find out how to get mod_rewrite to work with forms, and so far the only thing I've found out is that it is impossible?

I have this perl script, and I've used mod_rewrite to make my URLs SE-friendly. Good.
I also want to cloack the real myscript.cgi?action=mailform and myscript.cgi?action=processmailform urls in reference to experts saying hiding what programming language I use is wise.

myscript.cgi?action=mailform is fine, it's accessable through http://mydomain.com/category/mailform/

myscript.cgi?action=processmailform actually is accessable too, but only throws back the internal error check outputs I've coded for missing fields input, even though every field is filled out. In other words, all input values seems to get lost between the two calls for myscript.cgi.

So, is it impossible to do what I want with mod_rewrite, and if so, is there another way of achieving my goal?
malmklang
 
Posts: 17
Joined: Mon Mar 12, 2007 6:54 am

Postby richardk » Mon Mar 12, 2007 2:26 pm

What rules are you using? Are they GET (query string) variables or POST variables? If they're GET variables, have you got the QSA flag? A normal RewriteRule should not break a POST form.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby malmklang » Mon Mar 12, 2007 3:01 pm

I'm using post, not get. Forgot to mention that
http://mydomain.com/category/processmailform/ loses the input values, whereas
myscript.cgi?action=processmailform doesn't.

Sorry about wierd-looking names, it's norwegian, but I hope you can sort out the meaning nonetheless :P

Code: Select all
RewriteEngine on
RewriteBase /

RewriteRule ^kategorier/([0-9a-zA-Z]+)$/kategorier/$1/ [R]
RewriteRule ^kategorier/([0-9a-zA-Z]+)/?$ /hpg.cgi?id=$1/

RewriteRule ^kategorier/([0-9a-zA-Z]+)$/utskriftsvennlig/kategorier/$1/utskriftsvennlig/ [R]
RewriteRule ^kategorier/([0-9a-zA-Z]+)/utskriftsvennlig/?$ /hpg.cgi?id=$1&versjon=utskriftsvennlig/
malmklang
 
Posts: 17
Joined: Mon Mar 12, 2007 6:54 am

Postby richardk » Mon Mar 12, 2007 3:16 pm

If you redirect (to append the trailing slash) you will probably loose the POST variables. Make sure you have a trailing slash in your form actions.

You shouldn't have rules that match the same thing. The third rule should never run.

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^kategorier/([0-9a-zA-Z]+)$   %{REQUEST_URI}/ [R=301,L]
RewriteRule ^kategorier/([0-9a-zA-Z]+)/?$ ./hpg.cgi?id=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby malmklang » Mon Mar 12, 2007 3:21 pm

I'll go try :)

But the third rule isn't the same... it is for printer friendly versions of the previous rules or urls. Like : http://domain.com/category/main/printerfriendly/

But I'll probably do some re-coding of the script so that I don't need those last rules.

I'll report back, thanks so far :)
malmklang
 
Posts: 17
Joined: Mon Mar 12, 2007 6:54 am

Postby richardk » Mon Mar 12, 2007 3:28 pm

Ah, i see. You're missing a few spaces in the rules you posted.

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^kategorier/([0-9a-zA-Z]+)(/utskriftsvennlig)?$   %{REQUEST_URI}/          [R=301,L]
RewriteRule ^kategorier/([0-9a-zA-Z]+)/?$                     ./hpg.cgi?id=$1            [QSA,L]
RewriteRule ^kategorier/([0-9a-zA-Z]+)/(utskriftsvennlig)/?$  ./hpg.cgi?id=$1&versjon=$2 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby malmklang » Mon Mar 12, 2007 3:28 pm

http://malmklang.no/kategorier/skrevneord/

With your suggested code. Seems something's off somewhere.... the .htaccess file is in the root folder as is hpg.cgi :)
malmklang
 
Posts: 17
Joined: Mon Mar 12, 2007 6:54 am

Postby richardk » Mon Mar 12, 2007 3:46 pm

Try removing the "." from before /hpg.cgi.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby malmklang » Mon Mar 12, 2007 4:05 pm

http://malmklang.no/kategorier/kontakt/

Back to scratch, that is, the rules are more compact now, thanks for that tweak :)

Try to fill in name and such, and get my missing fields error subs back :P

mayhap my host's server's messed up?
malmklang
 
Posts: 17
Joined: Mon Mar 12, 2007 6:54 am

Postby richardk » Tue Mar 13, 2007 10:06 am

mayhap my host's server's messed up?

Possibly. Or it might be how CGI is getting the POST information. Do you have a different language to try with?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Next

Return to Security with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 12 guests

cron