LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 01-26-2012, 07:57 AM   #1
Sabinou
Member
 
Registered: Jan 2006
Location: France
Distribution: Debian Squeeze, Webmin + Virtualmin (remote dedi)
Posts: 212

Rep: Reputation: 30
Smile Cropping too long URLs


Hello,

On a blog I'm hosting, a stupid bot tries to send very long comments, but this idiotic software actually fails to do so and they end up as /page/x/?s= search queries. And when these reach the limit of above 512 characters, my wordpress blog engine goes mad and suddenly everyone seeing a page on which there was a search (the index page is unaffected) also gets the search query too.
Since a good number of people have this bug and sometimes it is "brought back" by visitors who come back after a while, there's no really a way to tell who's the bot in order to blacklist him.

I figured the solution would first lie with Suhosin, but precisely, Suhosin already sets a limit of 512 characters per query.
I suppose there's a relation with 512+ characters per query, but I can't dig deeper than that.

I have hopes for another method, how to resort to mod_rewrite to crop URLs that are, simply, too long.

And so am I here, with a question, do you think that a
Code:
RewriteEngine On
RewriteCond %{QUERY_STRING}  .{500}
RewriteRule / - [forbidden]
Could do the job, and crop all URLs above 500 characters of length ?

Or would you see another way to use the mod_rewrite rules to achieve that result, pretty please with sugar on top ?

Thank you very much if you can help, I'll be grateful !
 
Old 01-26-2012, 01:01 PM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,910

Rep: Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326
Hi,

If you want to nuke URLs and not only queries longer that 500 characters, you should replace the QUERY_STRING with REQUEST_URI.
Otherwise a URIL, like: /some-long-URI-with-more-than-500-chars?q=less-than-500-chars will pass.
And you have a slight error in your rule, so try this:
Code:
RewriteEngine on
RewriteCond %{REQUEST_URI} .{500}
RewriteRule (.*) - [F]
Regards
 
1 members found this post helpful.
Old 01-28-2012, 08:37 AM   #3
Sabinou
Member
 
Registered: Jan 2006
Location: France
Distribution: Debian Squeeze, Webmin + Virtualmin (remote dedi)
Posts: 212

Original Poster
Rep: Reputation: 30
Hi Bathory, and thanks !

EDITED (at first it didn't work, my Apache took some time to take the changes into account) : thank you very much, Bathory, your code corrections worked

Last edited by Sabinou; 01-28-2012 at 08:57 AM.
 
  


Reply

Tags
mod_rewrite


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Printer cropping page kern68 Linux - Hardware 3 03-19-2011 09:50 PM
Cropping in postscript moravveji Linux - Software 1 08-09-2010 09:57 PM
GIMP - Cropping Files etc Rud Linux - Newbie 8 03-01-2009 01:56 PM
Long URLs - Slowing computer down? Rick Harvey General 3 12-20-2005 06:13 AM
how to check urls and stop internet urls in network gface Linux - Networking 5 03-24-2005 09:48 PM


All times are GMT -5. The time now is 01:33 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration