Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

Spam words in a query string to Joomla site - how to fix

...

         

rmeys

9:48 pm on Jun 27, 2012 (gmt 0)

10+ Year Member



A few days ago i got an email from google that some websites are backlinking me with urls containing spam queries.

I have a joomla site where I tested example.com/?y​rvn​=spam-keyword and see that while the URL in the address remains the same (with the ?y​rvn​= part included), the webpage has however resolved to example.com/keyword-here/.

How can i solve this problem in such a way that i can send the page to a 404 and lockout also any other query that is not used in my joomla site. I use apache... So maybe i can do it with .htaccess... But i dont know how!

g1smd

11:15 pm on Jun 27, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Do you have any URLs with query strings that are valid?

If not, you can send 404 for all query strings with just a few lines of mod_rewrite code.

rmeys

11:22 pm on Jun 27, 2012 (gmt 0)

10+ Year Member



Yes i do, but this one starts only with ?yvpr= and that one is not used...

rmeys

11:32 pm on Jun 27, 2012 (gmt 0)

10+ Year Member



What are the query strings to send it to a 404?

rmeys

6:18 pm on Jun 28, 2012 (gmt 0)

10+ Year Member



I placed these commands in my htaccess but it doesnt work:

RewriteCond %{QUERY_STRING} ^yrvn=(.*)
RewriteRule /* [replacer_a] [R=404,L]

My site is joomla by the way!

g1smd

6:36 pm on Jun 28, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



^yrvn=
will match only when this is the first parameter.

(.*)
is not needed as you aren't reusing what it captures.

/*
matches a request for
example.com//
or
example.com////////////////
or similar.

No idea what
[replacer_a]
is, but it is not valid syntax.

[R=404]
isn't needed. You only need a rewrite, not a redirect. A rewrite to any non-existent path will trigger the 404 response.


The code is literally this, exactly as shown:

RewriteCond %{QUERY_STRING} (^|&)yrvn=
RewriteRule .* /does_not_exist [L]


This code must be placed before the internal Joomla rewrites.

rmeys

7:36 pm on Jun 28, 2012 (gmt 0)

10+ Year Member



thanks a lot... i just placed it in my htaccess but it still works...

[edited by: tedster at 8:22 pm (utc) on Jun 28, 2012]

rmeys

7:54 pm on Jun 28, 2012 (gmt 0)

10+ Year Member



hmm well the link is like this site.com/?yrvn=canada-pharmacy&id=1

rmeys

12:48 am on Jun 29, 2012 (gmt 0)

10+ Year Member



hahaha, well i think because of the cache it didnt work before but mod_rewrite does work with:

6:36 pm on June 28, 2012 (gmt 0)

^yrvn= will match only when this is the first parameter.

(.*) is not needed as you aren't reusing what it captures.

/* matches a request for example.com// or example.com//////////////// or similar.

No idea what [replacer_a] is, but it is not valid syntax.

[R=404] isn't needed. You only need a rewrite, not a redirect. A rewrite to any non-existent path will trigger the 404 response.

RewriteCond %{QUERY_STRING} (^|&)yrvn=
RewriteRule .* /does_not_exist [L]

The only thing is that it gives me a 500 internal server error. How can i send it to a 404?

g1smd

12:59 am on Jun 29, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Add a question mark to the end of the target path:

RewriteCond %{QUERY_STRING} (^|&)yrvn=
RewriteRule .* /does_not_exist? [L]

rmeys

1:05 am on Jun 29, 2012 (gmt 0)

10+ Year Member



i just did but then it shows the homepage again and it doesnt show a 404...

g1smd

6:55 am on Jun 29, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Shouldn't be necessary, but try this:

RewriteCond %{QUERY_STRING} (^|&)yrvn=
RewriteCond %{REQUEST_URI} !^/does_not_exist
RewriteRule .* /does_not_exist? [L]

rmeys

2:58 pm on Jun 29, 2012 (gmt 0)

10+ Year Member



It shows the homepage again when i put:

RewriteCond %{QUERY_STRING} (^|&)yrvn=
RewriteCond %{REQUEST_URI} !^/does_not_exist
RewriteRule .* /does_not_exist? [L]

The site is joomla so maybe it is because of that but i am not sure.

g1smd

3:06 pm on Jun 29, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The rule order is important. This goes before the Joomla internal rewrite.

Click the 'Disable Smilies' button to make the code readable and/or use code tags here.

rmeys

6:16 pm on Jun 29, 2012 (gmt 0)

10+ Year Member



yes i did put it before the joomla part in the htaccess...