cypher
cypher

Reputation: 6992

Trying to hide a part of the url with mod_rewrite

I'm attempting to hide a part of an url from the address, because it's useless mouse coordinates sent due to input type="image"

The URL is:

www.example.com/search.html?mode=fulltext&query=HelloWorld&ssubmit.x=0&ssubmit.y=0

I want to hide the ssubmit.x and ssubmit.y part. I tried adding the following rule to .htaccess, but without success:

RewriteRule &ssubmit[\.]x=[0-9]+&ssubmit[\.]y=[0-9]+$  [L]

What am I doing wrong?

Upvotes: 2

Views: 406

Answers (1)

Gumbo
Gumbo

Reputation: 655269

RewriteRule can only check the URL path but not the query. You need to use RewriteCond to check the URL query, for example:

RewriteCond %{QUERY_STRING} ^(.*&)?ssubmit\.x=0&ssubmit\.y=0(&.*)?$
RewriteRule ^search\.html$ %{REQUEST_URI}?%1%2 [L,R=301]

But it is probably better if the ssubmit.x and ssubmit.y do not get into the URL. One solution would be to omit the name of the image submit button.

Upvotes: 2

Related Questions