By ujang.jelebu on
Hi all,
I wonder how to handle invalid query string in drupal while Clean URL turned on.
For example, my site received invalid query string like http://example.com/index.php?view=product. However, as the query not recognized by the site neither drupal, I would like to handle it with 404 page. Is it possible to achieve this?
** As for now, all invalid query returned my site front page. ;-(
Thanks in advance!
Comments
Which version of Drupal are
Which version of Drupal are you using?
Hello nevets, I'm using
Hello nevets,
I'm using drupal 6.4
404 page
You can set a 404 page under admin/settings/error-reporting. Once set this will redirect any pages that are not found at the current path to this page. I believe if not set, drupal will work its way backward through the path until it finds a match. So in your situation, it didn't find a correct path until it hit the home page, example.com.
404 page didn't help.
Hello bkildow,
Thanks for your suggestion. I did set a 404 page at the first place. Yes it did help with invalid 'clean-url' path but not invalid query string as mentioned earlier. It still showing my site's home page. Below query..
will redirect to 404 page. but...
will not!
Perhaps anyone could try a query start with index.php?... and see the result wither it uses 404 or not. For my site and other drupal at my localhost, no it didn't.
hello friend, any idea to
hello friend,
any idea to handle this? It come to my concern since google index not able to remove http://example.com/index.php?param=value, as homepage still come up even the query string was invalid.
thanks in advance!
Do you know what the HTTP
Do you know what the HTTP response status code is for those request? Is it 404 or 200 etc?
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Status code: 200 OK
Hello jmburnz,
My query string to drupal is http://example.com/index.php?param=value. Below is what i got from firefox's webdeveloper add-on :-
Status code show 200 OK. anything i can do with it?
The 200 means the request
The 200 means the request was ok. It turns out your URL is fine as far as Drupal is concerned. If you consider a url without clean urls on it would look something like http://example.com/index.php?q=somepath¶m=value. The only part of the query that Drupal directly cares about is the q=somepath, if it is missing Drupal will take you to the front page of the site ('node' by default). Drupal only considers the q= when determining what page to route to. Any other query parameters are handled by the code used to display the requested page.
Hello nevets, I understand
Hello nevets,
I understand and agree with 'if it is missing Drupal will take you to the front page of the site ('node' by default)'. But the issue was instead of taking user / crawler to front page, is it possible to show / sent 404 status to browser?
Thanks
Very clean url - kill all invalid query strings
@ujang.jelebu:
I have the same problem too, as google continue to index my old wordpress version of my site, which has dirty url, and when i switched to drupal, those indexed url from my old site still exist on my drupal installation. now i want to send a 404 message to the crawler until i read this post, but unfortunately i haven't found the answer here.
So I made a modification to filter invalid query string on index.php, since index.php handles most of drupal requests, to send 404 message to user or crawler. here it is:
I inserted these lines BEFORE "require_once './includes/bootstrap.inc';" :
this will simply send a 404 message to crawler/user if the request url is using a query string that has "non-q" GET variable.
I used this on my drupal 6.5 installation, and NOT REALLY SURE if this is the right way to handle this problem, or might have cause some side effect on other page.
Put in a feature request for
Put in a feature request for Global Redirect to handle this and similar stuff:
#386928: Redirect url with a bad/spammed query string?
My Drupal sites: