htaccess Elite

.htaccess tutorial


All times are UTC [ DST ]





Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: remove input image querystring co-ordinates with htaccess
PostPosted: 04 Sep 2008 22:32 
Offline

Joined: 04 Sep 2008 22:19
Posts: 3
I have a form like this:
Code:
<form method="get">
<input type="image" src="button.jpg" name="button" value="1" />
</form>

When you click on the button and submit the form, the resultant url is:
Code:
/mypage.php?button=1&button.x=3&button.y=4

I want to use htaccess to remove the co-ordinates from the querystring to leave:
Code:
/mypage.php?button=1

Can anybody help?

Thanks.


Top
 Profile  
 
 Post subject: Re: remove input image querystring co-ordinates with htaccess
PostPosted: 12 Sep 2008 05:42 
Offline

Joined: 30 Oct 2006 19:55
Posts: 99
maniac wrote:
When you click on the button and submit the form, the resultant url is:
Code:
/mypage.php?button=1&button.x=3&button.y=4

I want to use htaccess to remove the co-ordinates from the querystring to leave:
Code:
/mypage.php?button=1


Code:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} ^GET\ /mypage\.php.*\ HTTP/ [NC]
RewriteCond %{QUERY_STRING} button\. [NC]
RewriteRule ^mypage\.php$ /mypage.php? [C]
RewriteRule .* /mypage.php?button=1 [R,L]


Top
 Profile  
 
 Post subject: Re: remove input image querystring co-ordinates with htaccess
PostPosted: 12 Sep 2008 08:17 
Offline

Joined: 04 Sep 2008 22:19
Posts: 3
Thank you for your reply. I don't quite understand it, but from the looks of it, button=1 is hard coded. I was hoping to retain the value of whatever button was set to in the querystring (and any other querystring variables). So rather than simply replacing the entire querystring with button=1, I want to remove the button.x and button.y part and leave the rest as it is.

In fact, this would be more useful if it worked on any url too (not just mypage.php).

Sorry if I wasn't very clear or have mis-understood your solution.


Top
 Profile  
 
 Post subject: Re: remove input image querystring co-ordinates with htaccess
PostPosted: 12 Sep 2008 13:49 
Offline

Joined: 30 Oct 2006 19:55
Posts: 99
maniac wrote:
Thank you for your reply....Sorry if I wasn't very clear or have mis-understood your solution.


maniac, your clarification was close to perfect, very nice.. so here is some working code that I think does everything you want.

Code:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} ^GET\ /.*\ HTTP/ [NC]
RewriteCond %{QUERY_STRING} button\.(x|y) [NC]
RewriteCond %{QUERY_STRING} (.*)(button\.[xy]{1}=[0-9]+.?button\.[xy]{1}=[0-9]+.?)(.*) [NC]
RewriteRule .* %{REQUEST_URI}?%1%3 [R,L]


Top
 Profile  
 
 Post subject: Re: remove input image querystring co-ordinates with htaccess
PostPosted: 12 Sep 2008 18:58 
Offline

Joined: 04 Sep 2008 22:19
Posts: 3
Awesome!

This looks great. And it even makes sense to me!

Cheers mod_rewrite - you're my hero...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB