|
I want my server to send a 404 header if a URL with a query string is
requested. So if a browser or spider requests something
like
www. my_site .com?p=chair
they would get a 404...
But if they request
www. my_site .com/chair.htm
everything would be normal.
With some assistance this is what I have so far, but it isn't working
correctly. It always displays the 404, even when there is no question
mark in the URL. Also, I would like the page to stop displaying anything
after the "HTML>>>" if it sends the 404 error, but I'm not sure how to do
it:
if (isset($_SERVER["QUERY_STRING"])) {
header("HTTP/1.0 404 Not Found");
echo <<<HTML
<head>
<title>404 Not Found</title>
</head>
<body>
<h1>Not Found</h1>
The requested URL was not found on this server.
</body>
</html>
HTML>>>;
} | |
Share:
|
"wd" <n2*@nospam.invalid> wrote in message
news:pa****************************@nospam.invalid ... I want my server to send a 404 header if a URL with a query string is requested. So if a browser or spider requests something like www. my_site .com?p=chair they would get a 404...
But if they request www. my_site .com/chair.htm everything would be normal.
With some assistance this is what I have so far, but it isn't working correctly. It always displays the 404, even when there is no question mark in the URL. Also, I would like the page to stop displaying anything after the "HTML>>>" if it sends the 404 error, but I'm not sure how to do it:
if (isset($_SERVER["QUERY_STRING"])) { header("HTTP/1.0 404 Not Found"); echo <<<HTML
<head> <title>404 Not Found</title> </head> <body> <h1>Not Found</h1> The requested URL was not found on this server. </body> </html>
HTML>>>;
}
That's because $_SERVER["QUERY_STRING"] is *always* set, regardless of
whether there's a query string or not. You might want to compare it to an
empty string, or check its length. Checking whether it's set or not does
not check the content at all...
dave | | |
On Tue, 17 Jan 2006 12:06:45 +0000, d wrote: "wd" <n2*@nospam.invalid> wrote in message news:pa****************************@nospam.invalid ...I want my server to send a 404 header if a URL with a query string is requested. So if a browser or spider requests something like www. my_site .com?p=chair they would get a 404...
But if they request www. my_site .com/chair.htm everything would be normal.
With some assistance this is what I have so far, but it isn't working correctly. It always displays the 404, even when there is no question mark in the URL. Also, I would like the page to stop displaying anything after the "HTML>>>" if it sends the 404 error, but I'm not sure how to do it:
if (isset($_SERVER["QUERY_STRING"])) { header("HTTP/1.0 404 Not Found"); echo <<<HTML
<head> <title>404 Not Found</title> </head> <body> <h1>Not Found</h1> The requested URL was not found on this server. </body> </html>
HTML>>>;
}
That's because $_SERVER["QUERY_STRING"] is *always* set, regardless of whether there's a query string or not. You might want to compare it to an empty string, or check its length. Checking whether it's set or not does not check the content at all...
dave
So, the query_string just contains the URL that is requested? Could I
just see if the query_string contains a question mark and then send the
404 if a question mark is found? | | |
"wd" <n2*@nospam.invalid> wrote in message
news:pa****************************@nospam.invalid ... I want my server to send a 404 header if a URL with a query string is requested. So if a browser or spider requests something like www. my_site .com?p=chair they would get a 404...
But if they request www. my_site .com/chair.htm everything would be normal.
With some assistance this is what I have so far, but it isn't working correctly. It always displays the 404, even when there is no question mark in the URL. Also, I would like the page to stop displaying anything after the "HTML>>>" if it sends the 404 error, but I'm not sure how to do it:
if (isset($_SERVER["QUERY_STRING"])) {
Try something like if(sizeof($_GET)){...
--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg) | | |
"wd" <n2*@nospam.invalid> wrote in message
news:pa****************************@nospam.invalid ... On Tue, 17 Jan 2006 12:06:45 +0000, d wrote:
"wd" <n2*@nospam.invalid> wrote in message news:pa****************************@nospam.invalid ...I want my server to send a 404 header if a URL with a query string is requested. So if a browser or spider requests something like www. my_site .com?p=chair they would get a 404...
But if they request www. my_site .com/chair.htm everything would be normal.
With some assistance this is what I have so far, but it isn't working correctly. It always displays the 404, even when there is no question mark in the URL. Also, I would like the page to stop displaying anything after the "HTML>>>" if it sends the 404 error, but I'm not sure how to do it:
if (isset($_SERVER["QUERY_STRING"])) { header("HTTP/1.0 404 Not Found"); echo <<<HTML
<head> <title>404 Not Found</title> </head> <body> <h1>Not Found</h1> The requested URL was not found on this server. </body> </html>
HTML>>>;
}
That's because $_SERVER["QUERY_STRING"] is *always* set, regardless of whether there's a query string or not. You might want to compare it to an empty string, or check its length. Checking whether it's set or not does not check the content at all...
dave
So, the query_string just contains the URL that is requested? Could I just see if the query_string contains a question mark and then send the 404 if a question mark is found?
No, $_SERVER["QUERY_STRING"] is empty when there is no query string. If
there is a query string, say the page is: http://somesite.com/?something
then $_SERVER["QUERY_STRING"]=="something". Check to see if the string is
empty, and if it is empty, then you're OK. If it's not empty, then a query
string has been passed.
dave | | |
"Kimmo Laine" <sp**@outolempi.net> wrote in message
news:Dl*****************@reader1.news.jippii.net.. . "wd" <n2*@nospam.invalid> wrote in message news:pa****************************@nospam.invalid ...I want my server to send a 404 header if a URL with a query string is requested. So if a browser or spider requests something like www. my_site .com?p=chair they would get a 404...
But if they request www. my_site .com/chair.htm everything would be normal.
With some assistance this is what I have so far, but it isn't working correctly. It always displays the 404, even when there is no question mark in the URL. Also, I would like the page to stop displaying anything after the "HTML>>>" if it sends the 404 error, but I'm not sure how to do it:
if (isset($_SERVER["QUERY_STRING"])) {
Try something like if(sizeof($_GET)){...
Just do this:
if ($_SERVER["QUERY_STRING"]=="") {
// OK
} else {
// Query string present
}
-- "En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg) | | |
"d" <d@example.com> wrote in message
news:yf****************@text.news.blueyonder.co.uk ... "wd" <n2*@nospam.invalid> wrote in message news:pa****************************@nospam.invalid ... On Tue, 17 Jan 2006 12:06:45 +0000, d wrote:
"wd" <n2*@nospam.invalid> wrote in message news:pa****************************@nospam.invalid ... I want my server to send a 404 header if a URL with a query string is requested. So if a browser or spider requests something like www. my_site .com?p=chair they would get a 404...
But if they request www. my_site .com/chair.htm everything would be normal.
With some assistance this is what I have so far, but it isn't working correctly. It always displays the 404, even when there is no question mark in the URL. Also, I would like the page to stop displaying anything after the "HTML>>>" if it sends the 404 error, but I'm not sure how to do it:
if (isset($_SERVER["QUERY_STRING"])) { header("HTTP/1.0 404 Not Found"); echo <<<HTML
<head> <title>404 Not Found</title> </head> <body> <h1>Not Found</h1> The requested URL was not found on this server. </body> </html>
HTML>>>;
}
That's because $_SERVER["QUERY_STRING"] is *always* set, regardless of whether there's a query string or not. You might want to compare it to an empty string, or check its length. Checking whether it's set or not does not check the content at all...
dave
So, the query_string just contains the URL that is requested? Could I just see if the query_string contains a question mark and then send the 404 if a question mark is found?
No, $_SERVER["QUERY_STRING"] is empty when there is no query string. If there is a query string, say the page is:
http://somesite.com/?something
then $_SERVER["QUERY_STRING"]=="something". Check to see if the string is empty, and if it is empty, then you're OK. If it's not empty, then a query string has been passed.
dave
You can also use the empty() function, which upon reading has been quicker
for some people than a straight comparison, not that comparisons are
notoriously lenghthy in their execution, but even so... ;) | | |
d wrote: "wd" <n2*@nospam.invalid> wrote in message news:pa****************************@nospam.invalid ... I want my server to send a 404 header if a URL with a query string is requested. So if a browser or spider requests something like www. my_site .com?p=chair they would get a 404...
But if they request www. my_site .com/chair.htm everything would be normal.
With some assistance this is what I have so far, but it isn't working correctly. It always displays the 404, even when there is no question mark in the URL. Also, I would like the page to stop displaying anything after the "HTML>>>" if it sends the 404 error, but I'm not sure how to do it:
if (isset($_SERVER["QUERY_STRING"])) { header("HTTP/1.0 404 Not Found");
[snip]
That's because $_SERVER["QUERY_STRING"] is *always* set, regardless of whether there's a query string or not.
Not true. With apache, QUERY_STRING will always be set; however, with
other web server software (ie. MS IIS) it will never be set unless you
have done so yourself.
Therefore, to be more portable, you may want to do something more like this:
if(isset($_GET) && is_array($_GET) && count($_GET)){
header("HTTP/1.0 404 Not Found");
echo <<< HTML
<html>
<head>
<title>404 Not Found</title>
</head>
<body>
<h1>Not Found</h1>
The requested URL was not found on this server.
</body>
</html>
HTML;
exit;
}
--
Justin Koivisto, ZCE - ju****@koivi.com http://koivi.com | | |
"Justin Koivisto" <ju****@koivi.com> wrote in message
news:8f********************@onvoy.com... d wrote: "wd" <n2*@nospam.invalid> wrote in message news:pa****************************@nospam.invalid ... I want my server to send a 404 header if a URL with a query string is requested. So if a browser or spider requests something like www. my_site .com?p=chair they would get a 404...
But if they request www. my_site .com/chair.htm everything would be normal.
With some assistance this is what I have so far, but it isn't working correctly. It always displays the 404, even when there is no question mark in the URL. Also, I would like the page to stop displaying anything after the "HTML>>>" if it sends the 404 error, but I'm not sure how to do it:
if (isset($_SERVER["QUERY_STRING"])) { header("HTTP/1.0 404 Not Found"); [snip]
That's because $_SERVER["QUERY_STRING"] is *always* set, regardless of whether there's a query string or not.
Not true. With apache, QUERY_STRING will always be set; however, with other web server software (ie. MS IIS) it will never be set unless you have done so yourself.
Incorrect. I tested it with Apache and IIS. BOTH have
$_SERVER["QUERY_STRING"] set regardless of whether a query string is present
or not.
Therefore, to be more portable, you may want to do something more like this:
if(isset($_GET) && is_array($_GET) && count($_GET)){ header("HTTP/1.0 404 Not Found"); echo <<< HTML <html> <head> <title>404 Not Found</title> </head> <body> <h1>Not Found</h1> The requested URL was not found on this server. </body> </html> HTML; exit; }
I don't want to sound rude, but that's ridiculous. Just check to see if
$_SERVER["QUERY_STRING"] is a non-empty string. If it is, then hey-presto,
you're set. You don't need to call isset, is_array and count all in one go.
-- Justin Koivisto, ZCE - ju****@koivi.com http://koivi.com | | |
"Justin Koivisto" <ju****@koivi.com> wrote in message
news:8f********************@onvoy.com... d wrote: "wd" <n2*@nospam.invalid> wrote in message news:pa****************************@nospam.invalid ... I want my server to send a 404 header if a URL with a query string is requested. So if a browser or spider requests something like www. my_site .com?p=chair they would get a 404...
But if they request www. my_site .com/chair.htm everything would be normal.
With some assistance this is what I have so far, but it isn't working correctly. It always displays the 404, even when there is no question mark in the URL. Also, I would like the page to stop displaying anything after the "HTML>>>" if it sends the 404 error, but I'm not sure how to do it:
if (isset($_SERVER["QUERY_STRING"])) { header("HTTP/1.0 404 Not Found"); [snip]
That's because $_SERVER["QUERY_STRING"] is *always* set, regardless of whether there's a query string or not.
Not true. With apache, QUERY_STRING will always be set; however, with other web server software (ie. MS IIS) it will never be set unless you have done so yourself.
I turned off a module in our engine, and you are correct - IIS won't set
QUERY_STRING unless prompted to. Regardless, it still doesn't merit calling
isset, is_array, and count just to check whether a string is empty or not.
Therefore, to be more portable, you may want to do something more like this:
if(isset($_GET) && is_array($_GET) && count($_GET)){ header("HTTP/1.0 404 Not Found"); echo <<< HTML <html> <head> <title>404 Not Found</title> </head> <body> <h1>Not Found</h1> The requested URL was not found on this server. </body> </html> HTML; exit; }
-- Justin Koivisto, ZCE - ju****@koivi.com http://koivi.com | | |
"Justin Koivisto" <ju****@koivi.com> wrote in message
news:8f********************@onvoy.com... d wrote: "wd" <n2*@nospam.invalid> wrote in message news:pa****************************@nospam.invalid ... I want my server to send a 404 header if a URL with a query string is requested. So if a browser or spider requests something like www. my_site .com?p=chair they would get a 404...
But if they request www. my_site .com/chair.htm everything would be normal.
With some assistance this is what I have so far, but it isn't working correctly. It always displays the 404, even when there is no question mark in the URL. Also, I would like the page to stop displaying anything after the "HTML>>>" if it sends the 404 error, but I'm not sure how to do it:
if (isset($_SERVER["QUERY_STRING"])) { header("HTTP/1.0 404 Not Found"); [snip]
That's because $_SERVER["QUERY_STRING"] is *always* set, regardless of whether there's a query string or not.
Not true. With apache, QUERY_STRING will always be set; however, with other web server software (ie. MS IIS) it will never be set unless you have done so yourself.
Therefore, to be more portable, you may want to do something more like this:
And not to mention your method only works if the query string is actually a
string of get parameters. If you pass just a string (as in his example),
the $_GET array is empty....
if(isset($_GET) && is_array($_GET) && count($_GET)){ header("HTTP/1.0 404 Not Found"); echo <<< HTML <html> <head> <title>404 Not Found</title> </head> <body> <h1>Not Found</h1> The requested URL was not found on this server. </body> </html> HTML; exit; }
-- Justin Koivisto, ZCE - ju****@koivi.com http://koivi.com | | |
d wrote: "Justin Koivisto" <ju****@koivi.com> wrote in message news:8f********************@onvoy.com... d wrote: "wd" <n2*@nospam.invalid> wrote in message news:pa****************************@nospam.invalid ... I want my server to send a 404 header if a URL with a query string is requested. So if a browser or spider requests something like www. my_site .com?p=chair they would get a 404...
But if they request www. my_site .com/chair.htm everything would be normal.
With some assistance this is what I have so far, but it isn't working correctly. It always displays the 404, even when there is no question mark in the URL. Also, I would like the page to stop displaying anything after the "HTML>>>" if it sends the 404 error, but I'm not sure how to do it:
if (isset($_SERVER["QUERY_STRING"])) { header("HTTP/1.0 404 Not Found"); [snip]
That's because $_SERVER["QUERY_STRING"] is *always* set, regardless of whether there's a query string or not. Not true. With apache, QUERY_STRING will always be set; however, with other web server software (ie. MS IIS) it will never be set unless you have done so yourself.
Incorrect. I tested it with Apache and IIS. BOTH have $_SERVER["QUERY_STRING"] set regardless of whether a query string is present or not.
Just because your IIS server has it does not mean that is the default.
My install (and every other install that I have used) does not *ever*
have it set. My version is (as reported by $_SERVER['SERVER_SOFTWARE'])
"Microsoft-IIS/5.1" Therefore, to be more portable, you may want to do something more like this:
if(isset($_GET) && is_array($_GET) && count($_GET)){ header("HTTP/1.0 404 Not Found"); echo <<< HTML <html> <head> <title>404 Not Found</title> </head> <body> <h1>Not Found</h1> The requested URL was not found on this server. </body> </html> HTML; exit; }
I don't want to sound rude, but that's ridiculous.
....but you just did.
Just check to see if $_SERVER["QUERY_STRING"] is a non-empty string. If it is, then hey-presto, you're set. You don't need to call isset, is_array and count all in one go.
And then when you install to another server like Netscape? Zues? AOL?
Roxen? thttpd? The list goes on. You cannot *expect* a server to have
$_SERVER['QUERY_STRING'] set in all cases.
--
Justin Koivisto, ZCE - ju****@koivi.com http://koivi.com | | |
"Justin Koivisto" <ju****@koivi.com> wrote in message
news:3-********************@onvoy.com... d wrote: "Justin Koivisto" <ju****@koivi.com> wrote in message news:8f********************@onvoy.com... d wrote: "wd" <n2*@nospam.invalid> wrote in message news:pa****************************@nospam.invalid ... > I want my server to send a 404 header if a URL with a query string is > requested. So if a browser or spider requests something > like > www. my_site .com?p=chair > they would get a 404... > > But if they request > www. my_site .com/chair.htm > everything would be normal. > > With some assistance this is what I have so far, but it isn't working > correctly. It always displays the 404, even when there is no question > mark in the URL. Also, I would like the page to stop displaying > anything > after the "HTML>>>" if it sends the 404 error, but I'm not sure how to > do > it: > > if (isset($_SERVER["QUERY_STRING"])) { > header("HTTP/1.0 404 Not Found"); [snip]
That's because $_SERVER["QUERY_STRING"] is *always* set, regardless of whether there's a query string or not. Not true. With apache, QUERY_STRING will always be set; however, with other web server software (ie. MS IIS) it will never be set unless you have done so yourself.
Incorrect. I tested it with Apache and IIS. BOTH have $_SERVER["QUERY_STRING"] set regardless of whether a query string is present or not.
Just because your IIS server has it does not mean that is the default. My install (and every other install that I have used) does not *ever* have it set. My version is (as reported by $_SERVER['SERVER_SOFTWARE']) "Microsoft-IIS/5.1"
See my other posts. Therefore, to be more portable, you may want to do something more like this:
if(isset($_GET) && is_array($_GET) && count($_GET)){ header("HTTP/1.0 404 Not Found"); echo <<< HTML <html> <head> <title>404 Not Found</title> </head> <body> <h1>Not Found</h1> The requested URL was not found on this server. </body> </html> HTML; exit; }
I don't want to sound rude, but that's ridiculous.
...but you just did.
Just check to see if $_SERVER["QUERY_STRING"] is a non-empty string. If it is, then hey-presto, you're set. You don't need to call isset, is_array and count all in one go.
And then when you install to another server like Netscape? Zues? AOL? Roxen? thttpd? The list goes on. You cannot *expect* a server to have $_SERVER['QUERY_STRING'] set in all cases.
-- Justin Koivisto, ZCE - ju****@koivi.com http://koivi.com | | |
d wrote: And not to mention your method only works if the query string is actually a string of get parameters. If you pass just a string (as in his example), the $_GET array is empty....
What are you talking about? If you request:
example.com/page.php?mystring
Then the $_GET array will be:
array(
'mystring' => ""
)
--
Justin Koivisto, ZCE - ju****@koivi.com http://koivi.com | | |
"Justin Koivisto" <ju****@koivi.com> wrote in message
news:uu******************************@onvoy.com... d wrote: And not to mention your method only works if the query string is actually a string of get parameters. If you pass just a string (as in his example), the $_GET array is empty.... What are you talking about? If you request: example.com/page.php?mystring
Then the $_GET array will be: array( 'mystring' => "" )
I guess we have differing setups. Either way, your assertion of portability
is out of the window ;)
-- Justin Koivisto, ZCE - ju****@koivi.com http://koivi.com | | |
d wrote: I turned off a module in our engine, and you are correct - IIS won't set QUERY_STRING unless prompted to. Regardless, it still doesn't merit calling isset, is_array, and count just to check whether a string is empty or not.
It's not a string, it's an array. To each their own on how to check. I
just like to be complete - it gives less chance of bugs down the road.
When you've been doing full-time php development for 6 years, then you
can criticize my merit of how I do things.
--
Justin Koivisto, ZCE - ju****@koivi.com http://koivi.com | | |
d wrote: "Justin Koivisto" <ju****@koivi.com> wrote in message news:uu******************************@onvoy.com... d wrote: And not to mention your method only works if the query string is actually a string of get parameters. If you pass just a string (as in his example), the $_GET array is empty.... What are you talking about? If you request: example.com/page.php?mystring
Then the $_GET array will be: array( 'mystring' => "" )
I guess we have differing setups. Either way, your assertion of portability is out of the window ;)
*PLONK*
--
Justin Koivisto, ZCE - ju****@koivi.com http://koivi.com | | |
"Justin Koivisto" <ju****@koivi.com> wrote in message
news:ve********************@onvoy.com... d wrote: I turned off a module in our engine, and you are correct - IIS won't set QUERY_STRING unless prompted to. Regardless, it still doesn't merit calling isset, is_array, and count just to check whether a string is empty or not. It's not a string, it's an array. To each their own on how to check. I just like to be complete - it gives less chance of bugs down the road. When you've been doing full-time php development for 6 years, then you can criticize my merit of how I do things.
The $_SERVER["QUERY_STRING"] is a string. Checking an array constructed
from the contents of a string is pointless - just check the string. If you
want to use a mixture of constructs and functions to determine the
characteristics of an array over just checking whether a string is empty,
then go right ahead.
And, funnily enough, I've been coding PHP professionally "full-time" for 7
years, so it seems I can criticise the merit of how you do things. Thanks
for letting me know ;) -- Justin Koivisto, ZCE - ju****@koivi.com http://koivi.com | | |
"Justin Koivisto" <ju****@koivi.com> wrote in message
news:ve********************@onvoy.com... d wrote: "Justin Koivisto" <ju****@koivi.com> wrote in message news:uu******************************@onvoy.com... d wrote: And not to mention your method only works if the query string is actually a string of get parameters. If you pass just a string (as in his example), the $_GET array is empty.... What are you talking about? If you request: example.com/page.php?mystring
Then the $_GET array will be: array( 'mystring' => "" ) I guess we have differing setups. Either way, your assertion of portability is out of the window ;)
*PLONK*
Hardly.
-- Justin Koivisto, ZCE - ju****@koivi.com http://koivi.com | | |
d wrote: And, funnily enough, I've been coding PHP professionally "full-time" for 7 years, so it seems I can criticise the merit of how you do things. Thanks for letting me know ;)
and I bet you've been using the native session support for 7 years as
well...
--
Justin Koivisto, ZCE - ju****@koivi.com http://koivi.com | | |
"Justin Koivisto" <ju****@koivi.com> wrote in message
news:be********************@onvoy.com... d wrote: And, funnily enough, I've been coding PHP professionally "full-time" for 7 years, so it seems I can criticise the merit of how you do things. Thanks for letting me know ;) and I bet you've been using the native session support for 7 years as well...
Nice try ;) Session handling didn't come along until php4, as you well
know.
-- Justin Koivisto, ZCE - ju****@koivi.com http://koivi.com | | |
I just wanted to follow up on this thread. I finally got a chance to try
the recommended solutions and neither of the works.
I have an .htaccess file rewriting the URLs. So even though it looks like
the browser is visiting http://www.my_site.com/page1.html, PHP still
thinks the $_SERVER["QUERY_STRING"] is p=page1 (from http://www.my_site.com/index.php?p=page1).
So every page except the home page ends up as a 404 not found error.
In the end, this solution worked -- PHP reads the URL and looks for a
question mark:
<?php
$url_string = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if (strstr($url_string, '?')) {
header("HTTP/1.0 404 Not Found");
echo <<<HTML
<html>
<head>
<title>404 Not Found</title>
</head>
<body>
<h1>Not Found</h1>
The requested URL was not found on this server.
</body>
</html>
HTML;
exit;
}
?> | | |
Following on from wd's message. . .
Is 404 the most suitable 400-series status code?
--
PETER FOX Not the same since the bottom fell out of the bucket business pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk> | | |
On Sat, 18 Feb 2006 18:59:10 +0000, Peter Fox wrote: Following on from wd's message. . .
Is 404 the most suitable 400-series status code?
It would either have to be 404 or 410. Google spidered about 250 URLs on
the site that have duplicate content like this: http://www. my_site .com/index.php?p=12345 http://www. my_site .com/index.php?p=23456 http://www. my_site .com/index.php?p=239fj http://www. my_site .com/index.php?p=29fks http://www. my_site .com/index.php?p=20fks
I need those kinds of pages removed from Google's cache. Those pages
don't exist so Google thinks there are 250 web pages with the same content
as the home page. The site is being penalized because of it. From what
I've read on Google's webmaster guidelines, Google will only remove them
if it finds a 404 error message. Apparently, a 410 header will work also. | | |
Following on from wd's message. . . On Sat, 18 Feb 2006 18:59:10 +0000, Peter Fox wrote:
Following on from wd's message. . .
Is 404 the most suitable 400-series status code?
It would either have to be 404 or 410. Google spidered about 250 URLs on the site that have duplicate content like this:
http://www. my_site .com/index.php?p=12345 http://www. my_site .com/index.php?p=23456 http://www. my_site .com/index.php?p=239fj http://www. my_site .com/index.php?p=29fks http://www. my_site .com/index.php?p=20fks
I need those kinds of pages removed from Google's cache. Those pages don't exist so Google thinks there are 250 web pages with the same content as the home page. The site is being penalized because of it. From what I've read on Google's webmaster guidelines, Google will only remove them if it finds a 404 error message. Apparently, a 410 header will work also.
Ooo err!
Shouldn't you be returning 404 if foo doesn't exist when asked for with
index.php?p=foo rather than any ?p=... ? What happens if Joe Bloggs
types in one of the offending ?p=... or a valid ?p=... How do you
distinguish those cases?
--
PETER FOX Not the same since the bottom fell out of the bucket business pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk> | | |
On Sun, 19 Feb 2006 00:47:41 +0000, Peter Fox wrote: Ooo err!
Shouldn't you be returning 404 if foo doesn't exist when asked for with index.php?p=foo rather than any ?p=... ? What happens if Joe Bloggs types in one of the offending ?p=... or a valid ?p=... How do you distinguish those cases?
No need... .htaccess rewrites all urls for legitimate pages. If you ask
for anything with a ? in the URL you now get a 404. If you ask for the
rewritten URLs (no question mark), you get the correct pages. | | This discussion thread is closed Replies have been disabled for this discussion. Similar topics
3 posts
views
Thread by laurie |
last post: by
|
2 posts
views
Thread by Will |
last post: by
|
5 posts
views
Thread by ToMeK |
last post: by
|
3 posts
views
Thread by Dynamo |
last post: by
| |
2 posts
views
Thread by Adam Baker |
last post: by
| | | | | | | | | | | | | |